Newb -influx write to CSV question

Hi all, total newb here. I totally do not understand the documentation clearly. I’m trying to import a CSV.

CSV data
#datatype tag,measurement,dateTime
m,Hostname,CPU,DateTime
host11,8,2022-06-07 10:20:50.327
host2,16,2022-06-07 10:20:50.327
host3,12,2022-06-07 10:20:50.327

command
.\influx.exe write -b testbucket -o “myorghere” -t “mytokenhere” -p s --format=lp -f c:/test/example.csv

Error
invalid field formatdata: 400 Bad Request: unable to parse '#datatype tag,measurement,dateTime

1 Like

Hello Derek,

I am equally new and have the same difficulties. Did you finally get a solution to your worry?

what should we do to normal csv files before importing them to influxDB? Each time i try uploading I get the error message “Failed to upload the selected CSV: error in csv.from(): failed to read metadata: missing expected annotation datatype”

Kind regards

Peter

Nope, nothing yet. I’m going to play with it a little more today. I’m pretty sure its just my lack of understanding with the Syntax and how Tag, Measurement, etc, etc are used for particular data types. The documentation isn’t quite giving me that “ah ha” moment.

If I used the below link, I can import that CSV created from the examples in the documentation no problem. But I don’t understand why it works vs why it doesnt work with my data.

Write CSV data to InfluxDB | InfluxDB Cloud Documentation (influxdata.com)

@derek,
you are writing CSV, but you are telling the tool that format is line protocol. Remove the --format param and you will get a more relevant error, that your CSV needs some data (field) columns.

Also, the dateTime must be in RFC3339 format. Correct: 2022-06-07T10:20:50.327Z

@Prince
Finally got time to focus on this for a bit this morning. Got it working with my own data. Here is my example that is confirmed to work. Remove “dryrun” and it actually posts to my testbucket.

.\influx.exe write dryrun -b testbucket -t TOKENHERE -o MyORG -f C:/test/example2.csv --header “#constant measurement,ServerData” --header “#datatype tag,double,double,tag,dateTime:2006-01-02”

My example2.csv file is the data below.
hostname,cpu,ram,loc,date
Host01,8,16,LOC,2022-06-07
Host02,16,16,LOC,2022-06-07
Host03,12,16,LOC,2022-06-07
Host04,4,40,LOC,2022-06-07