Fix csv examples (#3345)
* 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 <michellemcfarland@Michelles-MBP.home> Co-authored-by: Michelle McFarland <michellemcfarland@Michelles-MBP-19.home> Co-authored-by: “mcfarlm3” <“58636946+mcfarlm3@users.noreply.github.com”> Co-authored-by: kelseiv <47797004+kelseiv@users.noreply.github.com>pull/3434/head^2
parent
bd3b6e1c90
commit
d71ca570cb
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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`
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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`
|
||||
|
|
|
|||
Loading…
Reference in New Issue