Created
April 7, 2019 11:35
-
-
Save sandgate-dev/385af65851ee2317285a3dd6ccbf999a to your computer and use it in GitHub Desktop.
Increase field limit to address _csv.Error: field larger than field limit (131072)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # _csv.Error: field larger than field limit (131072) | |
| # https://stackoverflow.com/a/15063941/5983691 | |
| def csv_field_limit(): | |
| maxInt = sys.maxsize | |
| decrement = True | |
| while decrement: | |
| # decrease the maxInt value by factor 10 | |
| # as long as the OverflowError occurs. | |
| decrement = False | |
| try: | |
| csv.field_size_limit(maxInt) | |
| except OverflowError: | |
| maxInt = int(maxInt/10) | |
| decrement = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment