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
35 stars 10 forks source link

TypeError: 'dict_keys' object is not subscriptable #10

Closed thcp closed 4 years ago

thcp commented 4 years ago

Hi,

I'm using the exact example provided on the readme with the following inputs:

export_csv_to_influx \
--csv demo.csv \
--dbname demo \
--measurement demo \
--tag_columns url \
--field_columns response_time \
--user myuser \
--password mypass \
--force_insert_even_csv_no_update True \
--server 127.0.0.1:8086

and the following error is being returned:

Traceback (most recent call last):
  File "/home/xx/bitbucket/python/collector/venv/bin/export_csv_to_influx", line 10, in <module>
    sys.exit(export_csv_to_influx())
  File "/home/xx/bitbucket/python/collector/venv/lib/python3.7/site-packages/ExportCsvToInflux/exporter_object.py", line 496, in export_csv_to_influx
    force_insert_even_csv_no_update=args.force_insert_even_csv_no_update)
  File "/home/xx/bitbucket/python/collector/venv/lib/python3.7/site-packages/ExportCsvToInflux/exporter_object.py", line 279, in export_csv_to_influx
    csv_object.add_columns_to_csv(file_name=csv_file_item, target=new_csv_file, data=data)
  File "/home/xx/bitbucket/python/collector/venv/lib/python3.7/site-packages/ExportCsvToInflux/csv_object.py", line 271, in add_columns_to_csv
    new_headers = [x.keys()[0] for x in data]
  File "/home/xx/bitbucket/python/collector/venv/lib/python3.7/site-packages/ExportCsvToInflux/csv_object.py", line 271, in <listcomp>
    new_headers = [x.keys()[0] for x in data]
TypeError: 'dict_keys' object is not subscriptable

Thanks for your time on writing this useful tool!

Bugazelle commented 4 years ago

Sorry, I have found the root cause. It is incompatible in Python3.

For python2.7 is working well.

Fixing is on the way. Thank you for raise the issue.

Bugazelle commented 4 years ago

@thcp the issue fixed. Please update the the version to 0.1.15

Please let me know if still have any issues

thcp commented 4 years ago

Sorry for the late reply, works perfectly, thanks for the quick fix!