Files
advotracker/crates/advotracker_client/src/services/exports/allianzdirectcall.rs
Ralf Zerres 5a9965751a advotracker: reorganize the project using a crate based structure
* advotracker: the framework project
* crate/advotrackerdb: implementation of the database backend
* crate/advotrackerd: implementation of the backend (daemon)
* crate/adovtracker: implementaton of the application (CLI and GUI)

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2021-03-08 04:32:11 +01:00

38 lines
1.0 KiB
Rust

/*
* advotracker - Hotline tackingtool for Advocats
*
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
* SPDX-License-Identifier: (0BSD or MIT)
*/
//use chrono::{Local, DateTime};
use locales::t;
use std::error::Error;
use tracing::trace;
/// export as csv format
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
/// https://blog.burntsushi.net/csv/
pub fn export(p: &mut String, lang: &str) -> Result<(), Box<dyn Error>> {
use std::fs::File;
use std::path::Path;
//use std::ffi::OsStr;
let mut res = t!("csv.export.started", lang);
let mut state = t!("state.started", lang);
trace!(target: "csv-export", process = ?res, state = ?state);
// Note: slash syntax also works on Windows!
let path = Path::new(p);
// open the file
let file = File::open(path)?;
trace!(target: "csv.export", extension = ?path.extension(), file = ?file);
state = t!("state.finished", lang);
res = t!("csv.export.finished", lang);
trace!(target: "csv-export", process = ?res, state = ?state);
Ok(())
}