![]() no \r or \n within reasonable distance from the start of the file, the line number reported by reader.line_num will be (unhelpfully) 1. Do this: print repr(open('my.csv', 'rb').read(200)) # dump 1st 200 bytes of fileĪnd carefully copy/paste (don't retype) the result into an edit of your question (not into a comment).Īlso note that if the file is really dodgy e.g. It will show unambiguously what you've got, in a platform independant fashion (which is helpful to helpers who are unaware what od is or does). Repr() is (or wants to be) your debugging friend. I would suggest that you do this even if using 'rb' makes the problem go away. If the csv module says that you have a "NULL" (silly message, should be "NUL") byte in your file, then you need to check out what is in your file. ![]() I also note that you have several files (all opened with 'rU' ?) but only one causing a problem. As far as I know, using 'rU' mode would mess you up if there are embedded \r in the data, but not cause any other dramas. ![]() However that may NOT be causing your current problem. As says, you should be opening your files in 'rb' mode, not 'rU' mode. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |