From d71ca570cb4ae174a7c9888ea4f33ebbfb6bb83e Mon Sep 17 00:00:00 2001 From: mcfarlm3 <58636946+mcfarlm3@users.noreply.github.com> Date: Tue, 23 Nov 2021 11:19:09 -0800 Subject: [PATCH] Fix csv examples (#3345) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * added comma between datatype and measurement * fixed flux csv example and clarified differences between influx write and flux csv syntax * fixed group annotation values and corrected link to annotations details * ported changes to v2.1 docs * Update content/influxdb/v2.1/write-data/developer-tools/csv.md Co-authored-by: Michelle McFarland Co-authored-by: Michelle McFarland Co-authored-by: “mcfarlm3” <“58636946+mcfarlm3@users.noreply.github.com”> Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com> --- .../reference/syntax/annotated-csv/_index.md | 20 +++++++++--------- .../v2.0/write-data/developer-tools/csv.md | 21 ++++++++++++------- .../reference/syntax/annotated-csv/_index.md | 20 +++++++++--------- .../v2.1/write-data/developer-tools/csv.md | 21 ++++++++++++------- 4 files changed, 46 insertions(+), 36 deletions(-) diff --git a/content/influxdb/v2.0/reference/syntax/annotated-csv/_index.md b/content/influxdb/v2.0/reference/syntax/annotated-csv/_index.md index c9da9d509..7d0116dc7 100644 --- a/content/influxdb/v2.0/reference/syntax/annotated-csv/_index.md +++ b/content/influxdb/v2.0/reference/syntax/annotated-csv/_index.md @@ -252,16 +252,16 @@ to read annotated CSV in Flux: ```js import "csv" -csvData = "#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string,string,double -#group,false,false,false,false,false,false,false,false -#default,,,,,,,, -,result,table,_start,_stop,_time,region,host,_value -,,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43 -,,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25 -,,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62 -,,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,west,A,62.73 -,,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,west,B,12.83 -,,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,west,C,51.62 +csvData = "#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string,string,double,string +#group,false,false,true,true,false,true,false,false,true +#default,,,,,,,,, +,result,table,_start,_stop,_time,region,host,_value,_measurement +,,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43,cpu +,,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25,cpu +,,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62,cpu +,,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,west,A,62.73,cpu +,,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,west,B,12.83,cpu +,,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,west,C,51.62,cpu " csv.from(csv: csvData) diff --git a/content/influxdb/v2.0/write-data/developer-tools/csv.md b/content/influxdb/v2.0/write-data/developer-tools/csv.md index 95bab79ca..8728d1da1 100644 --- a/content/influxdb/v2.0/write-data/developer-tools/csv.md +++ b/content/influxdb/v2.0/write-data/developer-tools/csv.md @@ -349,14 +349,10 @@ To replace an existing column header row with annotation shorthand: 1. Use the `--skipHeader` flag to ignore the existing column header row. 2. Use the `--header` flag to inject a new column header row that uses annotation shorthand. -{{% note %}} -`--skipHeader` is the same as `--skipHeader=1`. -{{% /note %}} - ```sh influx write -b example-bucket \ -f example.csv \ - --skipHeader + --skipHeader=1 --header="m|measurement,count|long|0,time|dateTime:RFC3339" ``` @@ -518,7 +514,6 @@ in the `boolean` datatype annotation. {{% flex-content %}} ##### CSV with non-default boolean values ``` -sep=; #datatype measurement,"boolean:y,Y,1:n,N,0",dateTime:RFC3339 m,verified,time example,y,2020-01-01T00:00:00Z @@ -586,8 +581,18 @@ csv.from(url: "https://influx-testdata.s3.amazonaws.com/noaa.csv") ``` {{% note %}} -#### Required columns -To write data to InfluxDB with Flux, data must include the following columns: +#### Required annotations and columns +To write CSV data to InfluxDB with Flux, you must include _all_ of the following annotations and columns: + +- `datatype` +- `group` +- `default` + +See [annotations](/influxdb/v2.0/reference/syntax/annotated-csv/#annotations) for more information. +With Flux, there must also be a comma between the annotation name and the annotation values (this differs from the `influx write` command). +See an example of valid syntax for [annotated CSV in Flux](/influxdb/v2.1/reference/syntax/annotated-csv/#annotated-csv-in-flux). + +Required columns: - `_time` - `_measurement` diff --git a/content/influxdb/v2.1/reference/syntax/annotated-csv/_index.md b/content/influxdb/v2.1/reference/syntax/annotated-csv/_index.md index 5d904f74f..628630c30 100644 --- a/content/influxdb/v2.1/reference/syntax/annotated-csv/_index.md +++ b/content/influxdb/v2.1/reference/syntax/annotated-csv/_index.md @@ -252,16 +252,16 @@ to read annotated CSV in Flux: ```js import "csv" -csvData = "#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string,string,double -#group,false,false,false,false,false,false,false,false -#default,,,,,,,, -,result,table,_start,_stop,_time,region,host,_value -,,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43 -,,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25 -,,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62 -,,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,west,A,62.73 -,,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,west,B,12.83 -,,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,west,C,51.62 +csvData = "#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string,string,double,string +#group,false,false,true,true,false,true,false,false,true +#default,,,,,,,,, +,result,table,_start,_stop,_time,region,host,_value,_measurement +,,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43,cpu +,,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25,cpu +,,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62,cpu +,,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,west,A,62.73,cpu +,,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,west,B,12.83,cpu +,,1,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,west,C,51.62,cpu " csv.from(csv: csvData) diff --git a/content/influxdb/v2.1/write-data/developer-tools/csv.md b/content/influxdb/v2.1/write-data/developer-tools/csv.md index 9bcb685a3..8d091698b 100644 --- a/content/influxdb/v2.1/write-data/developer-tools/csv.md +++ b/content/influxdb/v2.1/write-data/developer-tools/csv.md @@ -349,14 +349,10 @@ To replace an existing column header row with annotation shorthand: 1. Use the `--skipHeader` flag to ignore the existing column header row. 2. Use the `--header` flag to inject a new column header row that uses annotation shorthand. -{{% note %}} -`--skipHeader` is the same as `--skipHeader=1`. -{{% /note %}} - ```sh influx write -b example-bucket \ -f example.csv \ - --skipHeader + --skipHeader=1 --header="m|measurement,count|long|0,time|dateTime:RFC3339" ``` @@ -518,7 +514,6 @@ in the `boolean` datatype annotation. {{% flex-content %}} ##### CSV with non-default boolean values ``` -sep=; #datatype measurement,"boolean:y,Y,1:n,N,0",dateTime:RFC3339 m,verified,time example,y,2020-01-01T00:00:00Z @@ -586,8 +581,18 @@ csv.from(url: "https://influx-testdata.s3.amazonaws.com/noaa.csv") ``` {{% note %}} -#### Required columns -To write data to InfluxDB with Flux, data must include the following columns: +#### Required annotations and columns +To write CSV data to InfluxDB with Flux, you must include _all_ of the following annotations and columns: + +- `datatype` +- `group` +- `default` + +See [annotations](/influxdb/v2.1/reference/syntax/annotated-csv/#annotations) for more information. +With Flux, you must also include a comma between the annotation name and the annotation values (this differs from the `influx write` command). +See an example of valid syntax for [annotated CSV in Flux](/influxdb/v2.1/reference/syntax/annotated-csv/#annotated-csv-in-flux). + +Required columns: - `_time` - `_measurement`