I have a CSV file from a small business that represents their records for about 70,000 orders spread out over about 30 years. My goal is to store this data in a Django project with a DecimalField in the model setup to receive the import.
Before trying to store the data in Django I'm first trying to import this data into Python. While most of the records import fine there are about 1 in 1000 that throw off a <class 'decimal.ConversionSyntax'> error during the import. This is causing me to get incorrect data into Python. I need to either fix how it reads the data or fix the problem in the data itself.
None of this has resolved the issue.
How can I figure out what is wrong with this data and resolve this error?
You can use chardet
to detect the encoding.
import chardet
with open('csv_of_text.csv','rb') as fraw: # "rb" = bytes mode
file_content = fraw.read()
chardet.detect(file_content)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.