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