chore: move csv_path_p, restructure modules
This commit is contained in:
@ -4,6 +4,11 @@ use anyhow::{Context, Result};
|
|||||||
use csv::ReaderBuilder;
|
use csv::ReaderBuilder;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
|
pub fn csv_path_p(path: &Path) -> bool {
|
||||||
|
path.extension()
|
||||||
|
.is_some_and(|ext| ext.eq_ignore_ascii_case("csv"))
|
||||||
|
}
|
||||||
|
|
||||||
/// Parse a CSV file and return records as serde_json::Value array
|
/// Parse a CSV file and return records as serde_json::Value array
|
||||||
pub fn parse_csv(path: &Path) -> Result<Vec<Value>> {
|
pub fn parse_csv(path: &Path) -> Result<Vec<Value>> {
|
||||||
let mut reader = ReaderBuilder::new()
|
let mut reader = ReaderBuilder::new()
|
||||||
|
|||||||
@ -7,7 +7,9 @@ mod persistence;
|
|||||||
mod ui;
|
mod ui;
|
||||||
mod view;
|
mod view;
|
||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
use crate::import::csv_parser::csv_path_p;
|
||||||
|
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
|
|
||||||
@ -42,11 +44,6 @@ impl Runnable for CmdLineArgs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn csv_path_p(path: &Path) -> bool {
|
|
||||||
path.extension()
|
|
||||||
.is_some_and(|ext| ext.eq_ignore_ascii_case("csv"))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_import_data(path: PathBuf) -> Option<Value> {
|
fn get_import_data(path: PathBuf) -> Option<Value> {
|
||||||
match std::fs::read_to_string(&path) {
|
match std::fs::read_to_string(&path) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
pub mod category;
|
pub mod category;
|
||||||
pub mod cell;
|
pub mod cell;
|
||||||
pub mod model;
|
pub mod types;
|
||||||
|
|
||||||
pub use model::Model;
|
pub use types::Model;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
pub mod axis;
|
pub mod axis;
|
||||||
pub mod layout;
|
pub mod layout;
|
||||||
pub mod view;
|
pub mod types;
|
||||||
|
|
||||||
pub use axis::Axis;
|
pub use axis::Axis;
|
||||||
pub use layout::{AxisEntry, GridLayout};
|
pub use layout::{AxisEntry, GridLayout};
|
||||||
pub use view::View;
|
pub use types::View;
|
||||||
|
|||||||
Reference in New Issue
Block a user