I am using the xlrd library to read an excel file. After acquiring the excel file contents that I need, I add the contents into a dictionary, then add the dictionary into a list.
all_data = []
data = {
'first_name': worksheet.cell_value(i, 0),
'last_name': worksheet.cell_value(i, 1),
'organization': worksheet.cell_value(i, 3),
'location': worksheet.cell_value(i, 29),
'university': worksheet.cell_value(i, 19),
'interests': worksheet2.cell_value(x, 22)
'dinner': worksheet2.cell_value(x, 23)
'film' = worksheet2.cell_value(x, 24)
}
all_data.append(data)
After doing so, I loop through each dictionary in the list and add additional information gathered from another excel sheet.
When dump the list into a text file, I get strings such as \\xe2\\x80\\x9c
and \\xe2\\x80\\x9d
. I am pretty sure it is an encoding issue, but I do not know how to fix this.
I wrote the file to the txt file with:
with open('file.txt', 'w') as f:
f.write(str(all_data))
I also printed all_data
into cmd and received the same results, just to clarify.