Reputation: 4405
I am getting this message when writing to an excel file using xlwt:
row index (u'RN') not an int in range(65536)
The line throwing the error come from here:
sheet.write(x,fieldKey, row.OBJECTID)
Where x
is a counter I set to set the row value and fieldKey
is another counter to set the column value.
I don't know why I am getting this message because the value (u'RN') is a string value, but it's telling me that it is not an int in range(65536). I believe the range(65536) is the limit of the excel table. Again, I was only writing 18 records, so I don't see why this error came up. Can anyone help?
Thanks, Mike
Upvotes: 0
Views: 5609
Reputation: 41
This is because you can not write to excel for more than 65536 lines. (You can now in the xlsx format). I had the same issue, try .to_csv()
Upvotes: 4
Reputation: 53
you can change in row.py inside the def init(self, rowx, parent_sheet) the limit, let's make it x2 for example:
if not (isinstance(rowx, int) and 0 <= rowx <= 131071):
changed from
if not (isinstance(rowx, int) and 0 <= rowx <= 65536):
Upvotes: 0
Reputation: 409
According to this SO post the args to sheet.write should be ycoord,xcoord,value
so it should be something like sheet.write(0,0,answer1)
edited based on responses.
Upvotes: 1
Reputation: 2449
The error you are getting is because x
(the row index) isn't a number, but a string. Check the values you are passing to the sheet.write
method; the first two must be numbers (try printing them before making the call).
Upvotes: 1