Skip to content

Commit

Permalink
update log info
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkLoc committed Oct 8, 2024
1 parent 9a8415c commit 5814fed
Show file tree
Hide file tree
Showing 22 changed files with 31 additions and 60 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "xtab"
version = "0.0.8"
version = "0.0.9"
authors = ["sharkLoc <[email protected]>"]
edition = "2021"
homepage = "https://github.com/sharkLoc/xtab"
description = "xtab: CSV command line utilities"
repository = "https://github.com/sharkLoc/xtab"
keywords = ["csv","tsv"]
keywords = ["csv","tsv","xlsx"]
categories = ["command-line-utilities"]
readme = "README.md"
license = "MIT"
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# xtab
🦀 CSV command line utilities

🦀 CSV command line utilities

## install
##### setp1:install cargo first

##### setp1:install cargo first

```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

##### step2:

```bash
cargo install xtab
# or
Expand All @@ -23,7 +26,7 @@ cargo b --release

```bash
xtab -- CSV command line utilities
Version: 0.0.8
Version: 0.0.9

Authors: sharkLoc <[email protected]>
Source code: https://github.com/sharkLoc/xtab.git
Expand Down
4 changes: 1 addition & 3 deletions src/command/addheader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::utils::*;
use anyhow::{Error, Ok};
use csv::{ReaderBuilder, StringRecord, WriterBuilder};
use log::info;
use std::{path::PathBuf, time::Instant};
use std::path::PathBuf;

pub fn addheader_csv(
new_header: String,
Expand All @@ -12,7 +12,6 @@ pub fn addheader_csv(
csvo: Option<PathBuf>,
compression_level: u32,
) -> Result<(), Error> {
let start = Instant::now();

let mut csv_reader = ReaderBuilder::new()
.delimiter(delimiter)
Expand All @@ -39,6 +38,5 @@ pub fn addheader_csv(
}
csv_writer.flush()?;

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
4 changes: 1 addition & 3 deletions src/command/csv2xlsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::{Error, Ok};
use csv::ReaderBuilder;
use log::info;
use rust_xlsxwriter::{Format, FormatBorder, Workbook};
use std::{path::PathBuf, time::Instant};
use std::path::PathBuf;

pub fn csv_xlsx(
no_header: bool,
Expand All @@ -13,7 +13,6 @@ pub fn csv_xlsx(
csv: Option<PathBuf>,
xlsx: &str,
) -> Result<(), Error> {
let start = Instant::now();

let mut csv_reader = ReaderBuilder::new()
.has_headers(no_header)
Expand Down Expand Up @@ -47,6 +46,5 @@ pub fn csv_xlsx(
}
work_book.save(xlsx)?;

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
4 changes: 1 addition & 3 deletions src/command/dim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::utils::*;
use anyhow::{Error, Ok};
use csv::ReaderBuilder;
use log::*;
use std::{path::PathBuf, time::Instant};
use std::path::PathBuf;

pub fn dim_csv(
no_header: bool,
Expand All @@ -11,7 +11,6 @@ pub fn dim_csv(
csvo: Option<PathBuf>,
compression_level: u32,
) -> Result<(), Error> {
let start = Instant::now();

let mut csv_reader = ReaderBuilder::new()
.has_headers(no_header)
Expand Down Expand Up @@ -53,6 +52,5 @@ pub fn dim_csv(
out_writer.write_all(buf.as_bytes())?;
out_writer.flush()?;

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
4 changes: 1 addition & 3 deletions src/command/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::utils::*;
use anyhow::{Error, Ok};
use csv::{ReaderBuilder, StringRecord, WriterBuilder};
use log::*;
use std::{path::PathBuf, time::Instant};
use std::path::PathBuf;

#[allow(clippy::too_many_arguments)]
pub fn drop_csv(
Expand All @@ -15,7 +15,6 @@ pub fn drop_csv(
csvo: Option<PathBuf>,
compression_level: u32,
) -> Result<(), Error> {
let start = Instant::now();

let mut csv_reader = ReaderBuilder::new()
.has_headers(no_header)
Expand Down Expand Up @@ -64,6 +63,5 @@ pub fn drop_csv(
}
csv_writer.flush()?;

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
4 changes: 1 addition & 3 deletions src/command/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::utils::*;
use anyhow::{Error, Ok};
use csv::{ReaderBuilder, StringRecord, WriterBuilder};
use log::*;
use std::{path::PathBuf, time::Instant};
use std::path::PathBuf;

pub fn flatten_csv(
no_header: bool,
Expand All @@ -13,7 +13,6 @@ pub fn flatten_csv(
csvo: Option<PathBuf>,
compression_level: u32,
) -> Result<(), Error> {
let start = Instant::now();

let mut csv_reader = ReaderBuilder::new()
.has_headers(no_header)
Expand Down Expand Up @@ -55,6 +54,5 @@ pub fn flatten_csv(
}
csv_writer.flush()?;

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
4 changes: 1 addition & 3 deletions src/command/freq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::utils::*;
use anyhow::{Error, Ok};
use csv::{ReaderBuilder, StringRecord, WriterBuilder};
use log::*;
use std::{collections::HashMap, path::PathBuf, time::Instant};
use std::{collections::HashMap, path::PathBuf};

#[allow(clippy::too_many_arguments)]
pub fn freq_csv(
Expand All @@ -17,7 +17,6 @@ pub fn freq_csv(
csvo: Option<PathBuf>,
compression_level: u32,
) -> Result<(), Error> {
let start = Instant::now();

let mut csv_reader = ReaderBuilder::new()
.has_headers(no_header)
Expand Down Expand Up @@ -130,6 +129,5 @@ pub fn freq_csv(
}
csv_writer.flush()?;

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
4 changes: 1 addition & 3 deletions src/command/head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::utils::*;
use anyhow::{Error, Ok};
use csv::{ReaderBuilder, WriterBuilder};
use log::*;
use std::{path::PathBuf, time::Instant};
use std::path::PathBuf;

pub fn head_csv(
no_header: bool,
Expand All @@ -13,7 +13,6 @@ pub fn head_csv(
csvo: Option<PathBuf>,
compression_level: u32,
) -> Result<(), Error> {
let start = Instant::now();

let mut csv_reader = ReaderBuilder::new()
.has_headers(no_header)
Expand All @@ -36,6 +35,5 @@ pub fn head_csv(
}
csv_writer.flush()?;

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
4 changes: 1 addition & 3 deletions src/command/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::{Error, Ok};
use comfy_table::{modifiers::UTF8_ROUND_CORNERS, presets::UTF8_FULL, *};
use csv::ReaderBuilder;
use log::*;
use std::{path::PathBuf, time::Instant};
use std::path::PathBuf;

pub fn pretty_csv(
no_header: bool,
Expand All @@ -14,7 +14,6 @@ pub fn pretty_csv(
header: bool,
csv: Option<PathBuf>,
) -> Result<(), Error> {
let start = Instant::now();

let mut csv_reader = ReaderBuilder::new()
.has_headers(no_header)
Expand Down Expand Up @@ -67,6 +66,5 @@ pub fn pretty_csv(
}
println!("{}", table);

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
4 changes: 1 addition & 3 deletions src/command/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::utils::*;
use anyhow::{Error, Ok};
use csv::{ReaderBuilder, StringRecord, WriterBuilder};
use log::*;
use std::{path::PathBuf, time::Instant};
use std::path::PathBuf;

#[allow(clippy::too_many_arguments)]
pub fn replace_csv(
Expand All @@ -17,7 +17,6 @@ pub fn replace_csv(
csvo: Option<PathBuf>,
compression_level: u32,
) -> Result<(), Error> {
let start = Instant::now();

let mut csv_reader = ReaderBuilder::new()
.has_headers(no_header)
Expand Down Expand Up @@ -71,6 +70,5 @@ pub fn replace_csv(
csv_writer.flush()?;

info!("total replace cell count: {}", count);
info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
4 changes: 1 addition & 3 deletions src/command/reverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::utils::*;
use anyhow::{Error, Ok};
use csv::{ReaderBuilder, WriterBuilder};
use log::*;
use std::{path::PathBuf, time::Instant};
use std::path::PathBuf;

pub fn reverse_csv(
no_header: bool,
Expand All @@ -12,7 +12,6 @@ pub fn reverse_csv(
csvo: Option<PathBuf>,
compression_level: u32,
) -> Result<(), Error> {
let start = Instant::now();

let mut csv_reader = ReaderBuilder::new()
.has_headers(no_header)
Expand Down Expand Up @@ -42,6 +41,5 @@ pub fn reverse_csv(
}
csv_writer.flush()?;

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
4 changes: 1 addition & 3 deletions src/command/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use csv::{ReaderBuilder, WriterBuilder};
use log::*;
use rand::{prelude::*, Rng};
use rand_pcg::Pcg64;
use std::{path::PathBuf, time::Instant};
use std::path::PathBuf;

#[allow(clippy::too_many_arguments)]
pub fn sample_csv(
Expand All @@ -17,7 +17,6 @@ pub fn sample_csv(
csvo: Option<PathBuf>,
compression_level: u32,
) -> Result<(), Error> {
let start = Instant::now();

let mut csv_reader = ReaderBuilder::new()
.has_headers(no_header)
Expand Down Expand Up @@ -54,7 +53,6 @@ pub fn sample_csv(
csv_writer.write_record(rec)?;
}
csv_writer.flush()?;
info!("time elapsed is: {:?}", start.elapsed());

Ok(())
}
4 changes: 1 addition & 3 deletions src/command/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::{Error, Ok};
use csv::{ReaderBuilder, WriterBuilder};
use log::*;
use regex::RegexBuilder;
use std::{path::PathBuf, time::Instant};
use std::path::PathBuf;

#[allow(clippy::too_many_arguments)]
pub fn search_csv(
Expand All @@ -17,7 +17,6 @@ pub fn search_csv(
csvo: Option<PathBuf>,
compression_level: u32,
) -> Result<(), Error> {
let start = Instant::now();
let re = RegexBuilder::new(pat).case_insensitive(case).build()?;

let mut csv_reader = ReaderBuilder::new()
Expand Down Expand Up @@ -58,6 +57,5 @@ pub fn search_csv(
}
csv_writer.flush()?;

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
4 changes: 1 addition & 3 deletions src/command/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::utils::*;
use anyhow::{Error, Ok};
use csv::{ReaderBuilder, StringRecord, WriterBuilder};
use log::*;
use std::{path::PathBuf, time::Instant};
use std::path::PathBuf;

#[allow(clippy::too_many_arguments)]
pub fn slice_csv(
Expand All @@ -17,7 +17,6 @@ pub fn slice_csv(
csvo: Option<PathBuf>,
compression_level: u32,
) -> Result<(), Error> {
let start = Instant::now();

let mut csv_reader = ReaderBuilder::new()
.has_headers(no_header)
Expand Down Expand Up @@ -66,6 +65,5 @@ pub fn slice_csv(
}
csv_writer.flush()?;

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
4 changes: 1 addition & 3 deletions src/command/tail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::utils::*;
use anyhow::{Error, Ok};
use csv::{ReaderBuilder, WriterBuilder};
use log::*;
use std::{path::PathBuf, time::Instant};
use std::path::PathBuf;

#[allow(clippy::too_many_arguments)]
pub fn tail_csv(
Expand All @@ -15,7 +15,6 @@ pub fn tail_csv(
csvo: Option<PathBuf>,
compression_level: u32,
) -> Result<(), Error> {
let start = Instant::now();

let mut csv_reader = ReaderBuilder::new()
.has_headers(no_header)
Expand Down Expand Up @@ -50,6 +49,5 @@ pub fn tail_csv(

csv_writer.flush()?;

info!("time elapsed is: {:?}", start.elapsed());
Ok(())
}
Loading

0 comments on commit 5814fed

Please sign in to comment.