0

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

3
  • 1
    As you say the value is a string rn which is not an int - nevermind the range part... Commented Jul 12, 2013 at 22:28
  • Why are you passing u'RN' as a column index/coordinate? What do you expect that to do? Commented Jul 12, 2013 at 22:37
  • Ahhhh...I've been working on this for hours. I just found that I set x as a variable buried deep in my script in another instance. I actually tried looking for that earlier, but it just hit me now. Jon, your post made me look again. thanks for that. Commented Jul 12, 2013 at 22:39

4 Answers 4

4

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()

Sign up to request clarification or add additional context in comments.

Comments

1

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).

3 Comments

Well, maybe not clearly, but it seems likely that if you have a counter named x and a key named fieldKey, it's the latter that would hold a string u'RN'. But you're right, I'm making an assumption that could be wrong.
Thanks everyone. I had through I was passing x as a number until it was overwritten with another x variable I had set. Thanks for all your help!
1

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.

1 Comment

It's easier to remember if you call them row and col instead of y and x. Then the order seems natural, instead of backward.
0

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):

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.