Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dustin/csv2influx
CSV to InfluxDB conversion tool.
https://github.com/dustin/csv2influx
Last synced: 3 days ago
JSON representation
CSV to InfluxDB conversion tool.
- Host: GitHub
- URL: https://github.com/dustin/csv2influx
- Owner: dustin
- License: bsd-3-clause
- Created: 2020-11-07T22:14:43.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-01T04:00:19.000Z (about 3 years ago)
- Last Synced: 2024-11-04T13:02:36.885Z (about 2 months ago)
- Language: Haskell
- Size: 17.6 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
# csv2influx
This is a tool to convert csv files into [Influx Line
Protocol](influxline). I use it when I export some data from influxdb
I need to manipulate and send back.## Synopsis
```
Usage: csv2influx [-m|--measurement ARG] [-t|--tags ARG] [-f|--fields ARG]
[--time ARG] FILES...
Convert CSV to influxdb wire protocolAvailable options:
-m,--measurement ARG measurement column name (default: "measurement")
-t,--tags ARG tags column names (comma separated)
-f,--fields ARG field column names (comma separated)
--time ARG timestamp column name (default: "time")
-h,--help Show this help text
```## Example:
If you have a csv file named `env.csv` that looks like this:
```csv
name,time,sensor,site,temperature
env,1599612130709842134,freezer,site1,-10.82
env,1599612130743049304,freezer,site1,-10.82
env,1599612306307120495,freezer,site1,-10.82
```and you want to store the into InfluxDB under the measurement named by
the field `name` with tags named by `sensor` and `site`, a field value
named by `temperature` and the timestamp named by `time`, you'd run
the following command:```sh
csv2influx -m name -t sensor,site -f temperature --time time env.csv > env.lines
```and it'll spit out the following:
```
env,site=site1,sensor=freezer temperature=-10.82 1599612130709842134
env,site=site1,sensor=freezer temperature=-10.82 1599612130743049304
env,site=site1,sensor=freezer temperature=-10.82 1599612306307120495
```You can feed that into influxdb with a simple `curl` command:
```
curl -i -XPOST 'http://$myinfluxdb:8086/write?db=$dbname' --data-binary @env.lines
```[influxline]: https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/