Skip to main content

carta_readers/
tsv.rs

1//! Tab-separated value reader.
2//!
3//! Shares the table assembly and field tokenizer of the comma-separated reader but splits records
4//! on tabs with no quoting: every character is literal and a line break always ends a record.
5
6use carta_ast::Document;
7use carta_core::{Reader, ReaderOptions, Result};
8
9use crate::csv::{build_document, parse_records};
10
11/// Parses tab-separated values into a single table.
12#[derive(Debug, Default, Clone, Copy)]
13pub struct TsvReader;
14
15impl Reader for TsvReader {
16    fn read(&self, input: &str, _options: &ReaderOptions) -> Result<Document> {
17        Ok(build_document(parse_records(input, '\t', false)))
18    }
19}