Handle Multiline Cell Values in TSV/CSV
Convert data with newlines inside cell values between TSV and CSV. Understand how quoted fields preserve line breaks within cells.
Detailed Explanation
Multiline Cell Values
One of the trickiest aspects of CSV/TSV parsing is handling newline characters that appear inside field values rather than between rows. A properly implemented parser must distinguish between newlines that are row separators and newlines that are part of a field value.
Example: CSV with Multiline Address Fields
Name,Address,Phone
Alice,"123 Main Street
Apt 4B
New York, NY 10001",555-0101
Bob,"456 Oak Avenue
Suite 200",555-0102
Converted to TSV
Name Address Phone
Alice "123 Main Street
Apt 4B
New York, NY 10001" 555-0101
Bob "456 Oak Avenue
Suite 200" 555-0102
How Multiline Fields Work
The key rules for multiline fields are:
- Quoting required: Any field containing a newline character must be enclosed in quotes
- Parser state: The parser tracks whether it is inside a quoted field; newlines within quotes do not end the row
- Preservation: The exact newline characters (\n, \r\n, or \r) are preserved as-is within the field
Common Issues
Many simple CSV parsers break on multiline fields because they split input by newlines first and then parse each line individually. This approach fails when fields span multiple lines. The converter in this tool uses a character-by-character state machine parser that correctly handles all newline scenarios.
Preview Table
The data preview table displays multiline cell values in their entirety, with line breaks visible within table cells. This makes it easy to verify that multiline data is being parsed correctly before downloading the converted output.
Use Case
Converting address databases, customer records, or content management exports where fields contain multiline text such as addresses, descriptions, or notes.