tag:selfsolved.com,2005:/problems/python-csv-and-universal-newline-mode/sSolutions for: Python csv and universal-newline mode | SelfSolveda SelfSolved feed2009-11-15T23:31:16Z1SelfSolvedtag:selfsolved.com,2005:Array/69923141116740yliu
csv module is far less brittle with handling empty cells in Excel documents:
>> f = csv.reader(open("/Users/yliu/foo/data", "rU"), dialect=csv.excel_tab)
>> for row in f:
print row
Notice the file flag: "U". This should fix any CSV parsing issues when your Excel sheet is irregularly formatted and populated. Check the reference for an explanation as to what exactly is universal-newline mode.
The error message is exactly what it says on the tin.