Skip to content

Commit

Permalink
fix incomplete paths of last chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
Taepper committed Mar 5, 2025
1 parent db56235 commit 7d24798
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions split_into_sorted_chunks/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@ fn main() -> std::io::Result<()> {
// Process any remaining lines
if !lines.is_empty() {
let sorted_lines = sort_by(lines, &args.sort_field);
let chunk_file = format!("{}_{}.ndjson.zst", args.filename_stem, chunk_counter);
let file = File::create(Path::join(Path::new(output_path), &chunk_file))?;
let chunk_file: PathBuf = Path::join(
output_path,
format!("{}_{}.ndjson.zst", args.filename_stem, chunk_counter),
);
let file = File::create(chunk_file.clone())?;
let mut encoder = Encoder::new(file, 3)?;
write_ndjson_lines(&mut encoder, &sorted_lines)?;
encoder.finish()?;
println!("{chunk_file}");
println!("{}", chunk_file.as_path().to_str().unwrap());
}
Ok(())
}

0 comments on commit 7d24798

Please sign in to comment.