# InfluxDB Line Protocol ⇄ CSV Converter

Convert InfluxDB line protocol to CSV and CSV back to line protocol in your browser. Annotated CSV, tag/field mapping, RFC3339 or Unix timestamps. No upload.

## Run it

- **CLI:** `gizza tool line-protocol-csv-converter "cpu,host=host1,region=eu usage=64.23,busy=true 1577836800000000000"`
- **Web:** https://gizza.ai/tools/line-protocol-csv-converter/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/line-protocol-csv-converter/tool.json

## Inputs

- `data` — Line protocol or CSV _(field)_
- `direction` — Direction _(field)_
- `csv_layout` — CSV layout _(field)_
- `delimiter` — Delimiter _(field)_
- `timestamp_format` — CSV time format _(field)_
- `precision` — Line protocol precision _(field)_
- `emit_annotations` — Add #datatype row _(field)_
- `measurement` — Measurement (CSV → LP) _(field)_
- `tag_columns` — Tag columns (CSV → LP) _(field)_
- `field_columns` — Field columns (CSV → LP) _(field)_
- `time_column` — Time column (CSV → LP) _(field)_
- `number_type` — Whole numbers _(field)_
- `sort_keys` — Sort tag keys _(field)_
- `on_error` — On a bad row _(field)_

## Output

- Converted output (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `data` — Line protocol or CSV
- `direction` — Direction
- `csv_layout` — CSV layout
- `delimiter` — Delimiter
- `timestamp_format` — CSV time format
- `precision` — Line protocol precision
- `emit_annotations` — Add #datatype row
- `measurement` — Measurement (CSV → LP)
- `tag_columns` — Tag columns (CSV → LP)
- `field_columns` — Field columns (CSV → LP)
- `time_column` — Time column (CSV → LP)
- `number_type` — Whole numbers
- `sort_keys` — Sort tag keys
- `on_error` — On a bad row

Example: `https://gizza.ai/tools/line-protocol-csv-converter/?data=cpu%2Chost%3Dhost1%2Cregion%3Deu%20usage%3D64.23%2Cbusy%3Dtrue%201577836800000000000&direction=auto&csv_layout=wide&delimiter=comma&timestamp_format=rfc3339&precision=ns&emit_annotations=true&measurement=cpu&tag_columns=host%2Cregion&field_columns=usage%2Cfree&time_column=time&number_type=float&sort_keys=true&on_error=stop`

---

## About this tool

Use this converter when you need to inspect InfluxDB line protocol in a spreadsheet, or turn a CSV export into line protocol for `influx write`. It works both ways: line protocol becomes a wide or long CSV table, and CSV becomes escaped, typed line protocol with measurements, tags, fields, and timestamps in the right places.

Example line protocol input:

```text
cpu,host=host1,region=eu usage=64.23,busy=true 1577836800000000000
cpu,host=host2,region=us usage=12.5,busy=false 1577836800000000000
```

With the default wide CSV layout, that becomes columns for `measurement`, `time`, tag keys (`host`, `region`) and field keys (`busy`, `usage`). Turn on `emit_annotations` when you want a `#datatype` row that can round-trip through InfluxDB's annotated CSV import path. For CSV to line protocol, use the annotation rows, inline `name|datatype|default` headers, or the measurement/tag/field/time parameters to describe column roles.

Limits and edge cases: input is capped at 2,000,000 characters, 200,000 lines and 1,000 output columns. The parser supports common annotated CSV rows (`#datatype`, `#constant`, `#default`), standard line protocol escapes, RFC3339 timestamps and Unix timestamp precisions from seconds to nanoseconds. It does not implement timezone annotation rows, Go-style custom time layouts, locale-specific decimal separators, file/directory reads, or direct writes to an InfluxDB server.

## FAQ

<details>
<summary>What is the difference between wide and long CSV?</summary>

Wide CSV writes one row per line protocol point and creates one column for each distinct tag or field key. It is easiest to read in a spreadsheet. Long CSV writes one row per field value, with `field` and `value` columns; it is better for heterogeneous measurements or data tools that prefer tidy data.

</details>

<details>
<summary>How does CSV to line protocol decide which columns are tags and fields?</summary>

Annotated CSV rows and inline headers have priority. Without those, `measurement`, `tag_columns`, `field_columns`, and `time_column` tell the converter how to map columns. If `field_columns` is blank, every column that is not the measurement, a tag, or the time column becomes a field.

</details>

<details>
<summary>Does it preserve line protocol escaping and field types?</summary>

Yes. Measurements, tag keys, tag values, field keys and string field values are escaped according to their line protocol position. Integer (`1i`), unsigned (`1u`), float, boolean, and quoted string field values are parsed and emitted with their line protocol spelling.

</details>

<details>
<summary>Can it write directly to InfluxDB?</summary>

No. This is an offline text converter. Copy the generated line protocol into your import workflow, or download/copy the annotated CSV and use the InfluxDB CLI or API yourself. Keeping network writes out of the tool makes the result deterministic and safe to preview.

</details>

## Related tools

- [Absolute value, sign, or negation for a whole column](https://gizza.ai/tools/absolute-value-transformer/): Paste a column of numbers and apply absolute value, sign extraction (-1/0/1), sign flipping, or force-negative to every value at once, with rounding and an audit table.
- [Adjacency Matrix Converter](https://gizza.ai/tools/adjacency-matrix-converter/): Convert a graph between edge list, adjacency matrix, and incidence matrix — directed or undirected, weighted or not. Free, private, runs in your browser.
- [Amazon Order Analyzer](https://gizza.ai/tools/amazon-order-analyzer/): Paste an Amazon order-history CSV export to summarize total spend by month, top items, and category breakdowns. Browser-only, private, with Markdown or JSON output.
- [ARFF Converter](https://gizza.ai/tools/arff-converter/): Convert Weka ARFF datasets to CSV and CSV tables back to ARFF locally — nominal attributes, numeric types, dates, sparse rows, missing values, and type rows.
- [Avro to JSON Converter](https://gizza.ai/tools/avro-to-json/): Decode Apache Avro Object Container Files (.avro / OCF) to JSON, NDJSON, or the embedded schema — no .avsc needed, free and private in your browser.
