The Python Oracle

Python xlrd module

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Orient Looping

--

Chapters
00:00 Python Xlrd Module
00:52 Accepted Answer Score 2
01:20 Answer 2 Score 0
02:13 Thank you

--

Full question
https://stackoverflow.com/questions/1746...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #xlrd

#avk47



ACCEPTED ANSWER

Score 2


row_values returns a list of cell values with appropriate data types. Data type of each item in the list depends on the cell type in the source excel file.

There could be items with only string, float and int data types, see this mapping table (find there docs for Cell) for more info.

u just means that this is a unicode string. Documentation explains it pretty well.

Hope that helps.




ANSWER 2

Score 0


First things first!
I don't know which version of xlrd you are using but according to the latest version(xlrd 0.9.4 at the time of writing this answer):

row_values() 

will return you with the values in the row in the form of a list. This can be verified by typing:

>>> type(sh.row_values(2))
<type 'list'>

Next to get the values of the row including the data types, you can type the following:

>>> sh.row(2)

Which will return you something like this:

[number:12.0, text:u'test.0']

Meaning that the first item in the list is a number and the second item is a string or also called as text.

Finally the u in front of the string means that it is Unicode encoding. Remember that xlrd module will try to render each and every data in excel sheet to unicode encoding and so you are seeing u

xlrd module official documentation