Merge pull request #838 from influxdata/flux/experimental-csv

Flux experimental CSV package
pull/847/head
Scott Anderson 2020-03-13 14:30:41 -06:00 committed by GitHub
commit 68f7ce83dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 94 additions and 15 deletions

View File

@ -22,29 +22,17 @@ _**Function type:** Input_
```js
import "csv"
csv.from(file: "/path/to/data-file.csv")
csv.from(csv: csvData)
// OR
csv.from(csv: csvData)
csv.from(file: "/path/to/data-file.csv")
```
## Parameters
### file
The file path of the CSV file to query.
The path can be absolute or relative.
If relative, it is relative to the working directory of the `influxd` process.
_The CSV file must exist in the same file system running the `influxd` process._
{{% cloud-msg %}}
{{< cloud-name "short" >}} does not support the `file` parameter.
{{% /cloud-msg %}}
_**Data type:** String_
### csv
Raw CSV-formatted text.
Annotated CSV text.
{{% note %}}
CSV data must use Annotated CSV syntax and include all
@ -54,6 +42,20 @@ For more information, see [Annotated CSV](/v2.0/reference/syntax/annotated-csv/)
_**Data type:** String_
### file
The file path of the CSV file to query.
The path can be absolute or relative.
If relative, it is relative to the working directory of the `fluxd` process.
_The CSV file must exist in the same file system running the `fluxd` process._
{{% warn %}}
**InfluxDB OSS** and **{{< cloud-name "short" >}}** user interfaces do _**not**_ support the `file` parameter.
Neither allow access to the underlying filesystem.
However, the [Flux REPL](/v2.0/reference/cli/influx/repl/) does support the `file` parameter.
{{% /warn %}}
_**Data type:** String_
## Examples
### Query CSV data from a file

View File

@ -0,0 +1,23 @@
---
title: Flux CSV package
list_title: CSV package
description: >
The Flux Experimental CSV package provides functions for retrieving annotated CSV.
Import the `experimental/csv` package.
menu:
v2_0_ref:
name: CSV
identifier: CSV-exp
parent: Experimental
weight: 301
v2.0/tags: [functions, csv, package]
---
The Flux Experimental CSV package provides functions for retrieving annotated CSV.
Import the `experimental/csv` package:
```js
import "experimental/csv"
```
{{< children type="functions" show="pages" >}}

View File

@ -0,0 +1,53 @@
---
title: csv.from() function
description: >
The experimental `csv.from()` function retrieves annotated CSV from a URL.
menu:
v2_0_ref:
name: csv.from *
parent: CSV-exp
weight: 401
---
The experimental `csv.from()` function retrieves [annotated CSV](/v2.0/reference/syntax/annotated-csv/) **from a URL**.
{{% note %}}
The experimental `csv.from()` function is an alternative to the standard
[`csv.from()` function](/v2.0/reference/flux/stdlib/csv/from/).
{{% /note %}}
_**Function type:** Input_
```js
import "experimental/csv"
csv.from(url: "http://localhost:9999/")
```
## Parameters
### url
The URL to retrieve annotated CSV from.
_**Data type:** String_
## Examples
##### Query annotated CSV data from a remote URL
```js
import "experimental/csv"
csv.from(url: "http://mydomain.com/csv/example.csv")
|> filter(fn: (r) => r._measurement == "example-measurement")
```
## Function definition
```js
package csv
import c "csv"
import "experimental/http"
from = (url) => c.from(csv: string(v: http.get(url: url).body))
```

View File

@ -21,6 +21,7 @@ InfluxDB until the next InfluxDB v2.0 release._
### Features
- Hand-transpile `elapsed()` aggregate.
- Hand-transpile `cumulative_sum()`.
- Experimental `csv` package.
### Bug fixes
- Add response reader as dependency to tune response size.