•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 403,029 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,866 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums
Views: 541 | Replies: 3 | Solved
![]() |
•
•
Join Date: Jun 2008
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
Hello to everybody!
I'm new in Python ... and have some problem with reading Excel...
no matter that I've set format in Excel Text (for all my available data) - it get float value from it...
Ok: here is the code:
<code>
import xlrd
book=xlrd.open_workbook("C:/Py/aaa.xls")
sh=book.sheet_by_index(0)
print sh.cell_value(RowN,CellN)
# it prints 1.0
</code>
Can somebody give me good suggestion ?
Thanks
Slava
I'm new in Python ... and have some problem with reading Excel...
no matter that I've set format in Excel Text (for all my available data) - it get float value from it...
Ok: here is the code:
<code>
import xlrd
book=xlrd.open_workbook("C:/Py/aaa.xls")
sh=book.sheet_by_index(0)
print sh.cell_value(RowN,CellN)
# it prints 1.0
</code>
Can somebody give me good suggestion ?
Thanks
Slava
•
•
Join Date: Jun 2008
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
Hello to everybody!
I'm new in Python ... and have some problem with reading Excel...
no matter that I've set format in Excel Text (for all my available data) - it get float value from it...
Ok: here is the code:
import xlrd book=xlrd.open_workbook("C:/Py/aaa.xls") sh=book.sheet_by_index(0) print sh.cell_value(RowN,CellN) # it prints 1.0
Can somebody give me good suggestion ?
Thanks
Slava
Forgot to say: it not problem to use int(...), the problem - I really don't know what will be data in excel cel: string either integer or float ....
•
•
Join Date: Jun 2008
Location: Milano, Italy
Posts: 16
Reputation:
Rep Power: 1
Solved Threads: 2
hi,
I think that the float indicates the type of value. If I'm correct 0 is int and 1 is text
Anyway instead of that try this:
row_values(rowx, start_colx=0, end_colx=None)
col_values(colx, start_rowx=0, end_rowx=None)
each of them returns a sequence of values found in the cells belonging to a row/column.
the arguments are in order: (row/col to analyze, start col/row, end col/row) last two arguments are optional
when you have the list you can simply get the value you need from that.
see this
Let me know if this helps.
I think that the float indicates the type of value. If I'm correct 0 is int and 1 is text
Anyway instead of that try this:
row_values(rowx, start_colx=0, end_colx=None)
col_values(colx, start_rowx=0, end_rowx=None)
each of them returns a sequence of values found in the cells belonging to a row/column.
the arguments are in order: (row/col to analyze, start col/row, end col/row) last two arguments are optional
when you have the list you can simply get the value you need from that.
see this
python Syntax (Toggle Plain Text)
import xlrd book = xlrd.open_workbook("C:\Python25\Test.xls") sheet = book.sheet_by_index(0) column = sheet.col_values(0, start_colx=0, end_colx=None) row = sheet.col_values(2, start_rowx=0, end_rowx=1) print column print row print column[2] print row[:]
Let me know if this helps.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Python Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Unable to create an excel file in VB.net (VB.NET)
- Programming VBA: Reading excel into an Array (Visual Basic 4 / 5 / 6)
- Reading excel sheet into a recordset (Visual Basic 4 / 5 / 6)
- Reading from an excel file (VB.NET)
- reading from Excell (C++)
- Reading Excel File using JAVA (Java)
- Reading excel data using vb 6.0 (Visual Basic 4 / 5 / 6)
Other Threads in the Python Forum
- Previous Thread: subtype custom 'float'. How to?
- Next Thread: Urgent : Question on editing a python program ....


Linear Mode