skip to Main Content

Convert the text input file to JSON in Python

I am using python to convert the text input file to json. My Code: import json import re filename = "text.txt" text = {} pattern = re.compile(r's*([^=t]+)s*=s*(.*)') with open(filename, encoding='utf8') as file: for line in file: match = pattern.match(line.strip()) if…

VIEW QUESTION

Javascript – i suppose to recive random names and uppercase their first letter but when i put empty space in .split(' ') , my code breakdown

const capitalizeName = function (name) { const names = name.split(` `); const uppercasedName = []; for (const n of names) { //uppercasedName.push(n[0].toUpperCase() + n.slice(1)); uppercasedName.push(n.replace(n[0], n[0].toUpperCase())); } console.log(uppercasedName.join('')); }; capitalizeName('jessica ann smith davis '); console shows the problem lies in…

VIEW QUESTION

Javascript replace regex wildcard with dynamic text

I need to extract text but some parts are dynamic and change This is my var htts://query1.data.site.com/v7/finance/download/MYTEXT?period1=1664641287&period2=1696177287&interval=1d&events=history&includeAdjustedClose=true I need to take only MYTEXT These values changes MYTEXT 1664641287 1696177287 1d I tried with string.replace but I don't know how to…

VIEW QUESTION
Back To Top
Search