BurntSushi / BurntSushi/rust-csv
Trim only unquoted fields
- Dominant language
- Rust
- Stars
- 2k
- Forks
- 257
- PR merge metrics
- No merged PRs in 30d
Description
#### What version of the `csv` crate are you using?
1.2.1
#### Briefly describe the question, bug or feature request.
There are currently options for trimming fields. However, if a file has explicitly quoted fields, this strongly indicates that exactly what is within the quotes should be considered the field value. It would be very useful to have an option to only trim unquoted fields.
Alternatively, a way to get info about if a field was quoted or not when it was parsed would perhaps be even more helpful. This would allow anyone to implement the feature ourselves.
#### Include a complete program demonstrating a problem.
```rust
fn main() {
let text = "
Hello, World
Hello,\" This field starts with a space\"
";
let mut rdr = csv::ReaderBuilder::new()
.has_headers(false)
.trim(csv::Trim::All)
.from_reader(std::io::Cursor::new(&text));
for result in rdr.records() {
println!("{:?}", result.unwrap().iter().map(|r| r.to_string()).collect::>());
}
}
```
#### What is the observed behavior of the code above?
```text
["Hello", "World"]
["Hello", "This field starts with a space"]
```
#### What is the expected or desired behavior of the code above?
```
["Hello", "World"]
["Hello", " This field starts with a space"]
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.