Tabular data guides

Turn an event stream into a CSV with one row per event

·

Each line of an NDJSON log can be read independently. A CSV export also needs a consistent column order across all those lines.

NDJSON to CSV Converter

Collect fields from successive events

Enter {"id":1,"event":"open"} on line one and {"id":2,"ms":17} on line two. The table has columns id, event and ms. The second row contains 2, an empty event field and 17.

NDJSON community specification

Preserve line breaks in a message

A JSON string containing the escape sequence backslash-n decodes to a line feed. A CSV writer quotes the whole cell to keep that line feed within one logical record. When converting CSV to NDJSON, the line feed is escaped inside the output JSON string.

RFC 4180 — CSV format and media typeRFC 8259 — JSON data interchange format

Read an event field that first appears on line two

Paste one complete JSON object on each physical line. The purchase event introduces amount, a field absent from the preceding view event.

Activity stream
{"event":"view","sku":"A"}
{"event":"buy","sku":"A","amount":12}
  • Expect three columns in the order event, sku, amount. The first amount cell is empty and the second contains 12. If the downstream system distinguishes an absent amount from an explicitly empty string, retain the source event records.

Common questions

Can I paste a pretty-printed JSON array?

Use the JSON and CSV Converter for arrays. Here each nonblank input line must parse independently as one object.

How do I locate an error after a blank line?

Read the physical line number in the diagnostic. Blank lines count toward the location even though they do not produce records.

Sources

Put it into practice.

Related guides