I have an excel sheet like below, I need to read the values from the cell and compare with another file.
0 1 2 3 4 5
1100 ᄀ ᄁ ᄂ ᄃ ᄄ ᄅ
1120 ᄠ ᄡ ᄢ ᄣ ᄤ ᄥ
1140 ᅀ ᅁ ᅂ ᅃ ᅄ ᅅ
I have written the below piece of code after googling for opening and reading the contents of the excel sheet in python
import xlrd
file_location = "C:/Users/yepMe/Desktop/try/language.xlsx"
workbook = xlrd.open_workbook(file_location)
sheet = workbook.sheet_by_index(3)
data = [[sheet.cell_value(r,c) for c in range(sheet.ncols)] for r in range(sheet.nrows)]
print type(data)
print data[1][0]
Now this doesn't throw any error and prints 0.0 , but when I try to print any other value which tries to print the Korean characters like print data[2][2]
, it gives the below error:
print data[2][2]
File "C:\Python27\lib\encodings\cp437.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\u1121' in position 0: character maps to <undefined>,
Kindly tell me what needs to be done to get the Korean characters.
If I do print ord(data[2][2])
, it prints the unicode code point, but when I am trying to loop through it:
for char in data:
decVal = ord(char)
Traceback (most recent call last):
File "C:\Users\amondapr\Desktop\korean\fonts\ttfq_protima.py", line 78, in <mo
dule>
decVal = ord(char)
TypeError: ord() expected string of length 1, but list found
It gives the above error how do I fetch the values, what am I doing wrong?