mirror of
https://github.com/rust-lang-nursery/rust-cookbook
synced 2024-11-24 20:43:07 +00:00
Use spaces for CSV in indentation
The use of tabs for indentation made the example error due to finding more columns on the indented lines than intended. Use escaped newlines and line continuations to prevent the indentation from being part of the records.
This commit is contained in:
parent
752b035c1a
commit
cc02ec8507
1 changed files with 3 additions and 3 deletions
|
@ -18,9 +18,9 @@ struct Record {
|
|||
use csv::ReaderBuilder;
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
let data = "name\tplace\tid
|
||||
Mark\tMelbourne\t46
|
||||
Ashley\tZurich\t92";
|
||||
let data = "name\tplace\tid\n\
|
||||
Mark\tMelbourne\t46\n\
|
||||
Ashley\tZurich\t92";
|
||||
|
||||
let mut reader = ReaderBuilder::new().delimiter(b'\t').from_reader(data.as_bytes());
|
||||
for result in reader.deserialize::<Record>() {
|
||||
|
|
Loading…
Reference in a new issue