influxdata / influx-cli

CLI for managing resources in InfluxDB v2
MIT License
61 stars 22 forks source link

`influx write` with seperator does not work as without #517

Open DanielHabenicht opened 1 year ago

DanielHabenicht commented 1 year ago

The Example given in influxdb for csv import via CLI is as following, but executing the same commands with a different seperator produces errors. image

By the way: There is a typo in dataTime, it should be dateTime

Reproduction:

> influx version
Influx CLI 2.6.1 (git: 61c5b4d) build_date: 2022-12-29T15:41:09Z
> cat <<EOF > test.csv
date,sighted,loc
2020-01-01,12,Boise
2020-06-01,78,Boise
2020-01-01,54,Seattle
2020-06-01,112,Seattle
2020-01-01,9,Detroit
2020-06-01,135,Detroit
EOF
> influx write dryrun -b test   -f test.csv --header "#constant measurement,birds"   --header "#datatype dateTime:2006-01-02,long,tag"

birds,loc=Boise sighted=12i 1577836800000000000
birds,loc=Boise sighted=78i 1590969600000000000
birds,loc=Seattle sighted=54i 1577836800000000000
birds,loc=Seattle sighted=112i 1590969600000000000
birds,loc=Detroit sighted=9i 1577836800000000000
birds,loc=Detroit sighted=135i 1590969600000000000
> sed -i "s/,/;/g" test.csv
> influx write dryrun -b test -f test.csv --header "sep=;" --header "#constant measurement,birds" --header "#datatype dateTime:2006-01-02,long,tag"

2023/06/15 13:24:48 line 5: no measurement column found
2023/06/15 13:24:48 line 6: no measurement column found
2023/06/15 13:24:48 Unable to batcher to error-file: invalid argument
2023/06/15 13:24:48 line 7: no measurement column found
2023/06/15 13:24:48 Unable to batcher to error-file: invalid argument
2023/06/15 13:24:48 line 8: no measurement column found
2023/06/15 13:24:48 Unable to batcher to error-file: invalid argument
2023/06/15 13:24:48 line 9: no measurement column found
2023/06/15 13:24:48 Unable to batcher to error-file: invalid argument
2023/06/15 13:24:48 line 10: no measurement column found
2023/06/15 13:24:48 Unable to batcher to error-file: invalid argument

Another thing that came to my mind while trying to import big files is that influx write dryrun would greatly benefit from a --head or --max-lines <n> option. This way one could try the annotated header without the console exploding. (but thats probably a feature request).