floe_core/io/write/
mod.rs1pub mod accepted;
2pub mod csv;
3pub mod delta;
4pub mod iceberg;
5pub mod modes;
6pub mod parquet;
7
8use std::path::{Path, PathBuf};
9
10use crate::FloeResult;
11
12pub fn write_error_report(
13 output_path: &Path,
14 errors_per_row: &[Option<String>],
15) -> FloeResult<PathBuf> {
16 if let Some(parent) = output_path.parent() {
17 std::fs::create_dir_all(parent)?;
18 }
19 let mut items = Vec::new();
20 for (idx, err) in errors_per_row.iter().enumerate() {
21 if let Some(err) = err {
22 items.push(format!("{{\"row_index\":{},\"errors\":{}}}", idx, err));
23 }
24 }
25 let content = format!("[{}]", items.join(","));
26 std::fs::write(output_path, content)?;
27 Ok(output_path.to_path_buf())
28}
29
30pub fn write_rejected_raw(source_path: &Path, output_path: &Path) -> FloeResult<PathBuf> {
31 if let Some(parent) = output_path.parent() {
32 std::fs::create_dir_all(parent)?;
33 }
34 std::fs::copy(source_path, output_path)?;
35 Ok(output_path.to_path_buf())
36}