export-csv-to-influx icon indicating copy to clipboard operation
export-csv-to-influx copied to clipboard

Any requirement for csv file encoding ?

Open Gerry-liu opened this issue 4 years ago • 1 comments

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

Gerry-liu avatar Feb 08 '21 14:02 Gerry-liu

Hello @Gerry-liu

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

Bugazelle avatar Mar 12 '22 13:03 Bugazelle