| Crates.io | oak-csv |
| lib.rs | oak-csv |
| version | 0.0.1 |
| created_at | 2025-10-20 14:44:48.859969+00 |
| updated_at | 2026-01-23 04:19:03.533106+00 |
| description | High-performance incremental CSV parser for the oak ecosystem with flexible configuration, optimized for data parsing and tabular data processing. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1892033 |
| size | 50,072 |
High-performance incremental CSV parser for the oak ecosystem with flexible configuration, optimized for data processing and analysis.
Oak-csv is a robust parser for CSV, designed to handle complete CSV syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for data processing and analysis.
Basic example:
use oak_csv::CsvParser;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = CsvParser::new();
let csv_content = r#"
name,age,city,country
John Doe,25,New York,USA
Jane Smith,30,London,UK
Bob Johnson,35,Paris,France
"#;
let document = parser.parse_document(csv_content)?;
println!("Parsed CSV document with {} records.", document.records.len());
Ok(())
}
use oak_csv::{CsvParser, ast::Document};
let parser = CsvParser::new();
let csv_content = r#"
product_id,product_name,price,stock
001,Smartphone,599.99,50
002,Laptop,1299.99,25
003,Headphones,199.99,100
"#;
let document = parser.parse_document(csv_content)?;
println!("Headers: {:?}", document.headers);
println!("Records: {}", document.records.len());
use oak_csv::{CsvParser, ast::Record};
let parser = CsvParser::new();
let csv_content = "Alice,28,Engineer,Seattle";
let record = parser.parse_record(csv_content)?;
println!("Fields: {:?}", record.fields);
println!("Field count: {}", record.fields.len());
use oak_csv::{CsvParser, ast::Field};
let parser = CsvParser::new();
let field_content = "\"John \"JD\" Doe\"";
let field = parser.parse_field(field_content)?;
println!("Field value: {}", field.value);
println!("Quoted: {}", field.is_quoted);
use oak_csv::{CsvParser, lexer::Token};
let parser = CsvParser::new();
let tokens = parser.tokenize("name,age,city\nJohn,25,NYC")?;
for token in tokens {
println!("{:?}", token.kind);
}
use oak_csv::CsvParser;
let parser = CsvParser::new();
let invalid_csv = r#"
name,age,city
John,25,NYC
Jane,30 // Missing field
Bob,35,London,UK
"#;
match parser.parse_document(invalid_csv) {
Ok(document) => println!("Parsed CSV document successfully."),
Err(e) => {
println!("Parse error at line {} column {}: {}",
e.line(), e.column(), e.message());
if let Some(context) = e.context() {
println!("Error context: {}", context);
}
}
}
The parser generates a comprehensive AST with the following main structures:
Oak-csv integrates seamlessly with:
Check out the examples directory for comprehensive examples:
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.