Hello Community ,
I’m new to influx and trying to import existing data from a CSV file to influx (OSS) but currently facing an error which I can’t understand and doesn’t make sense to me, other than some limitations I don’t know of and can’t find in the docs.
If necessary: my code
The CSV (with the line, that gives me the following error message):
sep=;
Date;Entry Type;Value;Currencs;Category;Person;Account;Counter Account;Group;Note;Recurring;
"17.06.2019";"Expense";"-26,56";"EUR";"LS > Groceries";"";"Sparkasse Giro";"";"";"Penny vom 14.06. , falsches konto";"no";
Error:
Traceback (most recent call last):
File "/Users/simon/Repos/primoco-toolbox/primoco_toolbox.py", line 60, in <module>
main(sys.argv[1:])
File "/Users/simon/Repos/primoco-toolbox/primoco_toolbox.py", line 53, in main
influxImport()
File "/Users/simon/Repos/primoco-toolbox/primoco_toolbox.py", line 25, in influxImport
importer.startImport()
File "/Users/simon/Repos/primoco-toolbox/influx_importer.py", line 130, in startImport
self.writeDataFrameToInflux(dataFrame)
File "/Users/simon/Repos/primoco-toolbox/influx_importer.py", line 96, in writeDataFrameToInflux
write_client.write(
File "/usr/local/lib/python3.9/site-packages/influxdb_client/client/write_api.py", line 371, in write
results = list(map(write_payload, payloads.items()))
File "/usr/local/lib/python3.9/site-packages/influxdb_client/client/write_api.py", line 369, in write_payload
return self._post_write(_async_req, bucket, org, final_string, payload[0])
File "/usr/local/lib/python3.9/site-packages/influxdb_client/client/write_api.py", line 517, in _post_write
return self._write_service.post_write(org=org, bucket=bucket, body=body, precision=precision,
File "/usr/local/lib/python3.9/site-packages/influxdb_client/service/write_service.py", line 62, in post_write
(data) = self.post_write_with_http_info(org, bucket, body, **kwargs) # noqa: E501
File "/usr/local/lib/python3.9/site-packages/influxdb_client/service/write_service.py", line 166, in post_write_with_http_info
return self.api_client.call_api(
File "/usr/local/lib/python3.9/site-packages/influxdb_client/api_client.py", line 341, in call_api
return self.__call_api(resource_path, method,
File "/usr/local/lib/python3.9/site-packages/influxdb_client/api_client.py", line 171, in __call_api
response_data = self.request(
File "/usr/local/lib/python3.9/site-packages/influxdb_client/api_client.py", line 386, in request
return self.rest_client.POST(url,
File "/usr/local/lib/python3.9/site-packages/influxdb_client/rest.py", line 304, in POST
return self.request("POST", url,
File "/usr/local/lib/python3.9/site-packages/influxdb_client/rest.py", line 254, in request
raise ApiException(http_resp=r)
influxdb_client.rest.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json; charset=utf-8', 'X-Influxdb-Build': 'OSS', 'X-Influxdb-Version': '2.0.9', 'X-Platform-Error-Code': 'invalid', 'Date': 'Mon, 01 Nov 2021 12:34:52 GMT', 'Content-Length': '274'})
HTTP response body: {"code":"invalid","message":"unable to parse 'bookings,Account=Sparkasse\\\\ Giro,Category=LS\\\\ \u003e\\\\ Groceries,Entry\\ Type=Expense ,Currencs=\"EUR\",Note=\"Penny vom 14.06. falsches konto\",Recurring=\"no\",Value=-26.56 1560729600000864000': invalid field format"}
What I want is, that the columns “Entry Type”, “Person”, “Category”, “Account” are tags. The code is working and writing the data to influx without any problems if:
- I write the data with “Entry Type”, “Person”, “Category” as tags
- I write the data with “Entry Type”, “Person”, “Account” as tags
But as soon as I write the data with “Entry Type”, “Person”, “Category” AND “Account” as tags I get the mentioned error.
This tells me that my overall code is working fine, but it seems like there are some limitations I don’t know of.
I got the same error invalid field format
before I didn’t escape spaces, commas and equal signs in the tag values like explained in the docs. But I fixed that (prepareTagColumns
function in my code).
Any help welcome!