In general, I am trying to pull lines from an xls file and write them into a dictionary. When accessing the dictionary, I get these lines in unicode format. I tried to directly specify the encoding
streets =[] excel_file = xlrd.open_workbook('rivals.xls', encoding_override="cp866") sheet = excel_file.sheet_by_index(0) row_number = sheet.nrows if row_number > 0: for row in range (0, row_number): streets.append(str(sheet.row(row)[0]).replace('text:','').replace("'",'')) print streets It does not help, and also does not plow with other encodings. I tried to specify utf-16le, cp1251, cp1252. Nothing helps. How can I get a normal Russian text to be recorded, and not this rubbish incomprehensible, since I then use the values of the dictionary to insert into the web page, and it spoils me. Python version 2.7 on Linux
Added code.
I tried to do through decode
if row_number > 0: for row in range (0, row_number): streets.append(str(sheet.row(row)[0]).replace('text:','').replace("'",'').decode('unicode-escape')) It also did not work
Here is my xls file https://dropmefiles.com/NwGmc I want to make a dictionary from it, like ['Vladivostok, 100th anniversary of Vladivostok Avenue, 153', 'Vladivostok, Aleutskaya Street, 4', etc.]
Noticed now such a thing.
Before using decode, the received data was with double slashes, after with single digits
Did so:
streets =[] excel_file = xlrd.open_workbook('rivals.xls', encoding_override="UTF-8") sheet = excel_file.sheet_by_index(0) row_number = sheet.nrows if row_number > 0: for row in range (0, row_number): streets.append( sheet.cell_value(row, 0) +" " + sheet.cell_value(row, 1)) Did not help
Dictionary code:
def add_address_from(): if len(streets) > 0: street = streets[0] addr_from.clear() addr_from.send_keys(street) sleep(2) addr_from.send_keys(Keys.ARROW_DOWN) sleep(2) addr_from.send_keys(Keys.ENTER) del streets[0] sleep(1)
cp866you triedcp866? - Jazzis