Importing CSV Data to InfluxDB

Hi everyone,

I am trying to import a seemingly very simple CSV file into InfluxDB (which I run in Home Assistant). My CSV file looks like this:

time,group,measurement,unit,value
1626393600,Biometrics,Weight,lbs,178
1626393600,Biometrics,Sleep,hours,9.5
1626393600,Biometrics,Heart Rate (Samsung Health),bpm,95
1626393600,Biometrics,Mood,Rating,3
1626393600,Biometrics,Tinnitus,Rating,2
1626393600,Biometrics,Headaches,Rating,0
1626480000,Biometrics,Sleep,hours,8
1626480000,Biometrics,Weight,lbs,178
1626480000,Biometrics,Heart Rate (Samsung Health),bpm,111
1626480000,Biometrics,Mood,Rating,3
1626480000,Biometrics,Tinnitus,Rating,2
1626480000,Biometrics,Headaches,Rating,1.5
1626566400,Biometrics,Sleep,hours,4.25
1626566400,Biometrics,Weight,lbs,179.6
1626566400,Biometrics,Heart Rate (Samsung Health),bpm,79
1626566400,Biometrics,Mood,Rating,3
1626566400,Biometrics,Tinnitus,Rating,1.5
1626566400,Biometrics,Headaches,Rating,0
1626652800,Biometrics,Weight,lbs,182
1626652800,Biometrics,Sleep,hours,4.5
1626652800,Biometrics,Heart Rate (Samsung Health),bpm,68
1626652800,Biometrics,Mood,Rating,3
1626652800,Biometrics,Tinnitus,Rating,1.5
1626652800,Biometrics,Headaches,Rating,2
1626739200,Biometrics,Weight,lbs,181.2
1626739200,Biometrics,Sleep,hours,8
1626739200,Biometrics,Heart Rate (Samsung Health),bpm,104
1626739200,Biometrics,Mood,Rating,3.5
1626739200,Biometrics,Tinnitus,Rating,1.5
1626739200,Biometrics,Headaches,Rating,0
1626825600,Biometrics,Weight,lbs,181.2
1626825600,Biometrics,Heart Rate (Samsung Health),bpm,73

But whenever I try to write data to my InfluxDB database, it gives me this error:

Since I run InfluxDB in Home Assistant I’m not able to use any command line commands or Telegraph, just dragging and dropping CSV files directly into it to upload data. I’ve scoured the internet and really tried to understand what I’m doing wrong, but it’s escaping me. What am I doing wrong here, and what do I need to do to upload this data to InfluxDB? Thanks!

Which influxdb version are you using?

I took your csv data and tried it in InfluxDB Cloud 2.0, but I couldn’t get it to upload in the GUI either.
Even after adding the annotation rows #datatype, #group and #default it did not work.
I find the documentation a bit confusing in this regard.

https://docs.influxdata.com/influxdb/v2.0/reference/syntax/annotated-csv/

Maybe @Anaisdg can help?

I believe the current version of InfluxDB available through Home Assistant is 1.8.6. I may be wrong, but looking through the changelog that appears to be the newest version bump.

I managed to import data by copy/pasting the example here:

cpu,cpu=cpu1,host=host1 time_steal=0,usage_user=2.7 1482669077000000000
cpu,cpu=cpu1,host=host2 time_steal=0,usage_user=2.2 1482669087000000000

It appears as though it only accepts the line protocol itself, not the annotated CSV text like this:

#datatype measurement,tag,tag,field,field,ignored,time
m,cpu,host,time_steal,usage_user,nothing,time
cpu,cpu1,host1,0,2.7,a,1482669077000000000
cpu,cpu1,host2,0,2.2,b,1482669087000000000

However, despite this actually importing data into InfluxDB, I can’t query anything because there’s “no results”, as you can see here:

It should be plotting the usage_user values, which are 2.7 and 2.2, but it doesn’t seem to think they exist. Any ideas?

I only use InfluxDB 2.x and there you can choose between csv and influx when importing. If this option is not available, it could be that InfluxDB 1.x only supports influx as import format anyway.

I guess you have to select a suitable time window in the dashboard, otherwise you won’t get any results.
The timestamps are from 2016.

I do not have any option to select csv versus influx when importing. I can import CSV files, but unless the files are already in line protocol it doesn’t seem to work. The Home Assistant add-on must just not be 2.0 yet.

As for the no data issue…you’re right, it’s 2016, that’s why it didn’t show up. Thanks! All is working now, albeit a little cumbersome to format all my data into line protocol manually.