[READ-ONLY] Mirror of https://github.com/probablykasper/csv-pipeline.
0

Configure Feed

Select the types of activity you want to include in your feed.

Add `Pipeline::collect_into_rows()`

Kasper (May 25, 2023, 8:48 AM +0200) 3aede752 e58f4304

+12
+1
CHANGELOG.md
··· 3 3 ## Next 4 4 - Changed `from_pipelines` to accept an iterator instead of vector 5 5 - Add `Pipeline::from_rows()` 6 + - Add `Pipeline::collect_into_rows()` 6 7 7 8 ## 0.3.1 - 2023 Feb 17 8 9 - Fix `Pipeline::from_path` panic
+11
src/pipeline.rs
··· 467 467 self.build().run() 468 468 } 469 469 470 + pub fn collect_into_rows(self) -> Result<Vec<Row>, PlError> { 471 + let pipeline_iter = self.build(); 472 + let header_row = pipeline_iter.headers.get_row().clone(); 473 + let records: Result<Vec<Row>, PlError> = pipeline_iter.map(|record| record).collect(); 474 + let rows = vec![header_row] 475 + .into_iter() 476 + .chain(records?.into_iter()) 477 + .collect(); 478 + Ok(rows) 479 + } 480 + 470 481 pub fn collect_into_string(self) -> Result<String, PlError> { 471 482 let mut csv = String::new(); 472 483 self.flush(StringTarget::new(&mut csv)).run()?;