-
-
Notifications
You must be signed in to change notification settings - Fork 233
Open
Description
What version of the csv
crate are you using?
1.1.1
Briefly describe the question, bug or feature request.
The library skips the empty rows even when flexible is set to be true.
The default behavior in python csv library, Excel, Number is keeping empty rows, so I think we should follow that (the users may have hard time to find the different between the data they see in Excel and the result from the Rust code).
Include a complete program demonstrating a problem.
use csv; // 1.1.1
fn main() {
let s = "year,make\n\n1948,Porsche\n1967,Ford";
let reader = csv::ReaderBuilder::new()
.has_headers(false)
.flexible(true)
.from_reader(s.as_bytes());
for (i, record) in reader.into_records().enumerate() {
println!("row: {} - record: {:?}", i, record.unwrap());
}
}
What is the observed behavior of the code above?
row: 0 - record: StringRecord(["year", "make"])
row: 1 - record: StringRecord(["1948", "Porsche"])
row: 2 - record: StringRecord(["1967", "Ford"])
What is the expected or desired behavior of the code above?
row: 0 - record: StringRecord(["year", "make"])
row: 1 - record: StringRecord([])
row: 2 - record: StringRecord(["1948", "Porsche"])
row: 3 - record: StringRecord(["1967", "Ford"])
Here is the python code for the same csv:
import io, csv
s = "year,make\n\n1948,Porsche\n1967,Ford"
print(list(csv.reader(io.StringIO(s))))
# output >>> [['year', 'make'], [], ['1948', 'Porsche'], ['1967', 'Ford']]
sheepla
Metadata
Metadata
Assignees
Labels
No labels