Bugazelle / export-csv-to-influx

The python library to write the CSV data into Influx. Support me via Bitcoin: bc1qqgkmph9cvygzxfpupv4jr4n0nfx3qumwg39j5w
BSD 3-Clause "New" or "Revised" License
32 stars 11 forks source link

Any requirement for csv file encoding ? #45

Open Gerry-liu opened 3 years ago

Gerry-liu commented 3 years ago

Any requirement for csv file encoding ? I use the csv file generated by python dataframe.to_csv with 'utf_8_sig'. then got below errors. and the CSV file include chinese language. Many Thanks.

File "C:/WorkPlace/Python_Project/JQData/Upload_JQ_data.py", line 15, in exporter.export_csv_to_influx(csv_file="beishang_sh_change_20210201231306.csv",db_server_name="192.168.78.136:8086",db_user="admin",db_password="!234qwer",db_name="BeiShang",db_measurement="BeiShang",time_column="day",tag_columns="link_name,code,name",time_format="%Y-%m-%d",field_columns="share_number,share_ratio",batch_size=5000) File "C:\WorkPlace\Anaconda3\envs\Python_Project\lib\site-packages\ExportCsvToInflux\exporter_object.py", line 329, in export_csv_to_influx csv_file_length = csv_object.get_csv_lines_count(csv_file_item) File "C:\WorkPlace\Anaconda3\envs\Python_Project\lib\site-packages\ExportCsvToInflux\csv_object.py", line 136, in get_csv_lines_count has_header = self.get_csv_header(file_name) File "C:\WorkPlace\Anaconda3\envs\Python_Project\lib\site-packages\ExportCsvToInflux\csv_object.py", line 34, in get_csv_header has_header = sniffer.has_header(f.read(40960)) File "C:\WorkPlace\Anaconda3\envs\Python_Project\lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 118: character maps to

Bugazelle commented 2 years ago

Hello @Gerry-liu

The latest lib 0.2.0 should fix your issue Please upgrade the lib: pip install ExportCsvToInflux --upgrade