Rust code to generate a csv with 1 billion rows, also python script to be able to compare
Private research annotation
Sign in to add a private research label or note.
- User
Rust code to generate a csv with 1 billion rows, also python script to be able to compare
Assistant
Here is an example Rust code that generates a CSV file with 1 billion rows:
rustuse std::fs::File; use std::io::{BufWriter, Write}; use std::path::Path; fn main() { let file_path = "output.csv"; let mut file = BufWriter::new(File::create(file_path).unwrap()); for i in 0..1_000_000_000 { let row = format!("{},{}\n", i, i * 2); file.write_all(row.as_bytes()).unwrap(); } }This code uses the
std::fsandstd::iomodules to create a new file namedoutput.csvand write 1 billion rows to it. Each row is a simple CSV row with two columns: the first column is the row numberi, and the second column is the row number multiplied by 2.To compare with Python, here is an example Python script that generates the same CSV file:
python
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.