Linear TSV is a Python library providing a simple, line-oriented, and portable tabular data format. Unlike standard CSV, it uses escape codes for newlines and tabs within field data, enabling robust processing with line-oriented shell tools. The format aligns with the TEXT serialization mode of Postgres and MySQL, making it ideal for reliable data exchange. It is currently at version 1.1.0 and maintains an active release cadence.
pip install linear-tsvVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to parse a `linear-tsv` formatted string using the `tsv.un()` function. It shows how to handle embedded newlines and tabs using their defined escape sequences (`\n`, `\t`) and also the `\N` representation for `NULL` values. The `tsv.un()` function returns a generator of lists of strings.
Always use `linear-tsv.tsv.un()` for parsing files adhering to the linear-tsv format. If using other parsers, ensure they are configured to handle these specific escape sequences (e.g., `quoting=csv.QUOTE_NONE` in pandas and custom escape handling).
If your TSV file includes a header, you must manually separate the first row after parsing to use as column names. For example, `header = parsed_data[0]` and `data_rows = parsed_data[1:]`.
Post-process the parsed data to convert `"\\N"` strings to `None` or your desired representation for null values. Example: `[None if x == '\\N' else x for x in row]`.
No dependency data recorded yet.