I read csv files using csv reader, and then convert it into a json file using dictionary.
In doing so, I would like only letters and numbers with no non-ascii characters or nbsp. I am trying to do it like this:
with open ('/file', 'rb') as file_Read:
reader = csv.reader(file_Read)
lis = []
di = {}
for r in reader:
di = {r[0].strip():[some_val]}
lis.append(di)
with open('/file1', 'wb') as file_Dumped:
list_to_be_written = json.dumps(lis)
file_Dumped.write(liss)
When I read the file, the output, it consists of sequences like \xa0\xa0\xa0\xa0
along with the keys.
Ex - {"name \xa0\xa0\xa0\xa0":[9]}
If I do json.dumps(lis,ensure_ascii=False)
then I see blank spaces surrounding the keys.
Ex - {"name ":[9]}
How do I completely remove everything but letters and digits?