all Python 3Files & I/Ofunction
csv.field_size_limit()
csv — utilities
Returns or changes the maximum size of a single CSV field when reading. The default is 131072 characters (128 KiB).
Syntax
csv.field_size_limit([new_limit])
A field longer than the limit stops reading with csv.Error 'field larger than field limit' — common with CSV whose cells hold long text or JSON. It is also often a sign of a broken file: an unclosed quote glues the rest of the file into one field. Called with an argument it sets the new limit and returns the old one, and the setting applies to the whole process.
Examples
import csv
import io
print(csv.field_size_limit()) # → 131072
old = csv.field_size_limit(10)
try:
list(csv.reader(io.StringIO('x' * 20)))
except csv.Error as e:
print(e) # → field larger than field limit (10)
csv.field_size_limit(old)
See also
Open in the full glossarydocs.python.orgReport an inaccuracy