I am working on an excel workbook
. I am using python
script for operating on the workbook
. But there two issues:
1) There are some cells which have integer
values. When I am reading that values and putting the read value into a report file (.txt
), it is appending .0
with the number. Eg. if there is value 6, it is giving 6.0 when it is not supposed to do this. I have read that there is nothing as integer
in excel. Still, I have 1000s of parameters and thus, I cant convert directly all of them to integer
using some python
function because that may convert values which are actually float
also.
2) And when I am reading boolean
TRUE and FALSE, it is giving me 1 and 0. I want to get whatever text
I see in the excel workbook on my desktop. I don't want any conversions like that.
I am using xlrd
for excel
operations in python
.
Please tell me what I should do to solve this problem?
Note: My excel sheet contains more than 100 sheets and I can't modify "true or false" with "1 and 0" etc
However, sometimes when you open a workbook, you see that it is open but you can't actually see it. This could be as a result of an intentional or accidental hiding of the workbook (as apposed to a sheet). Under the VIEW tab you will see buttons called Hide and Unhide.
for the boolean question you can test ctype:
for rx in range(ws.nrows):
for cx in range(ws.ncols):
print ws.cell(rx,cx).value, ws.cell(rx,cx).ctype
if the excel original cell is "TRUE" FALSE" the ctype value is 4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With