_csv.Error: field larger than field limit (131072)

后端 未结 8 1993
有刺的猬
有刺的猬 2020-11-28 19:10

I have a script reading in a csv file with very huge fields:

# example from http://docs.python.org/3.3/library/csv.html?highlight=csv%20dictreader#examples
i         


        
8条回答
  •  情话喂你
    2020-11-28 19:31

    I just had this happen to me on a 'plain' CSV file. Some people might call it an invalid formatted file. No escape characters, no double quotes and delimiter was a semicolon.

    A sample line from this file would look like this:

    First cell; Second " Cell with one double quote and leading space;'Partially quoted' cell;Last cell

    the single quote in the second cell would throw the parser off its rails. What worked was:

    csv.reader(inputfile, delimiter=';', doublequote='False', quotechar='', quoting=csv.QUOTE_NONE)
    

提交回复
热议问题