Compare commits

..

10 commits

Author SHA1 Message Date
Mueez Khan
fa02eddc1e
chore: delete .github/FUNDING.yml 2025-03-07 06:57:15 -05:00
rzmk
5b8c057e5d
test(python): rename tests & add column count test 2024-06-25 21:19:24 -04:00
rzmk
1e7c4a1569
test(wasm): add column_count 2024-06-22 08:41:52 -04:00
rzmk
358fe0a8b9
test: add row count with header 2024-06-21 23:30:44 -04:00
rzmk
719f3e1512 docs: comment slice docstring while disabled 2024-06-21 05:55:20 -04:00
Mueez Khan
55835772ed
docs: fix czv-wasm node-demo 2024-06-21 01:32:09 -04:00
Mueez Khan
254e34fe05
docs: remove links to non-existent files 2024-06-21 01:18:45 -04:00
Mueez Khan
4e62cc2ecd
docs: fix Rust example to use include_header_row 2024-06-21 00:19:44 -04:00
rzmk
ad526cc717
docs: add docstring for ColumnCountBuilder::execute 2024-06-20 23:48:28 -04:00
rzmk
bdaf0eb853
docs: add link to https://docs.rs/czv 2024-06-20 23:38:46 -04:00
12 changed files with 66 additions and 18 deletions

1
.github/FUNDING.yml vendored
View file

@ -1 +0,0 @@
github: [rzmk]

View file

@ -5,7 +5,7 @@ czv includes libraries for Rust, Python, and WebAssembly (JavaScript and TypeScr
## Links ## Links
- czv GitHub repository: <https://github.com/rzmk/czv> - czv GitHub repository: <https://github.com/rzmk/czv>
- Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) - Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) ([docs](https://docs.rs/czv))
- WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm)) - WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm))
- Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python)) - Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python))
@ -29,8 +29,11 @@ apple,2.50
banana,3.00 banana,3.00
strawberry,1.50 strawberry,1.50
"; ";
let output: usize = RowCount::new().file_data(data).execute()?; let output: usize = RowCount::new()
println!("{output}"); // 3 .file_data(data)
.include_header_row(true)
.execute()?;
println!("{output}"); // 4
Ok(()) Ok(())
} }
``` ```

View file

@ -5,7 +5,7 @@ Python library for [czv](https://github.com/rzmk/czv). czv is a library of CSV-r
## Links ## Links
- czv GitHub repository: <https://github.com/rzmk/czv> - czv GitHub repository: <https://github.com/rzmk/czv>
- Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) - Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) ([docs](https://docs.rs/czv))
- WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm)) - WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm))
- Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python)) - Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python))

View file

@ -27,7 +27,7 @@ print(output) # 4
## Links ## Links
- czv GitHub repository: <https://github.com/rzmk/czv> - czv GitHub repository: <https://github.com/rzmk/czv>
- Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) - Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) ([docs](https://docs.rs/czv))
- WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm)) - WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm))
- Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python)) - Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python))

View file

@ -2,12 +2,12 @@ import czv
import pytest import pytest
from .test_data import test_data from .test_data import test_data
class TestCountFunc: class TestRowCount:
@pytest.mark.parametrize( @pytest.mark.parametrize(
"file_name,expected", "file_name,expected",
[("fruits.csv", 3), ("constituents_altnames.csv", 33971)], [("fruits.csv", 3), ("constituents_altnames.csv", 33971)],
) )
def test_count(self, file_name, expected): def test_row_count(self, file_name, expected):
"""Count the total number of non-header rows.""" """Count the total number of non-header rows."""
result = czv.row_count(file_path=test_data[file_name]) result = czv.row_count(file_path=test_data[file_name])
@ -17,8 +17,19 @@ class TestCountFunc:
"file_name,expected", "file_name,expected",
[("fruits.csv", 4), ("constituents_altnames.csv", 33972)], [("fruits.csv", 4), ("constituents_altnames.csv", 33972)],
) )
def test_include_header_row(self, file_name, expected): def test_row_count_include_header_row(self, file_name, expected):
"""Count the total number of rows including the header row.""" """Count the total number of rows including the header row."""
result = czv.row_count(file_path=test_data[file_name], include_header_row=True) result = czv.row_count(file_path=test_data[file_name], include_header_row=True)
assert result == expected assert result == expected
class TestColumnCount:
@pytest.mark.parametrize(
"file_name,expected",
[("fruits.csv", 2), ("constituents_altnames.csv", 6)],
)
def test_column_count(self, file_name, expected):
"""Count the total number of columns."""
result = czv.column_count(file_path=test_data[file_name])
assert result == expected

View file

@ -5,7 +5,7 @@ WebAssembly (JavaScript and TypeScript) library for [czv](https://github.com/rzm
## Links ## Links
- czv GitHub repository: <https://github.com/rzmk/czv> - czv GitHub repository: <https://github.com/rzmk/czv>
- Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) - Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) ([docs](https://docs.rs/czv))
- WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm)) - WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm))
- Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python)) - Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python))

View file

@ -1,3 +1,5 @@
// See the README.md file in this file's folder
// for how to run this example
import czv from "../../pkg/czv-ts"; import czv from "../../pkg/czv-ts";
const options: czv.RowCountOptions = { const options: czv.RowCountOptions = {
@ -5,6 +7,7 @@ const options: czv.RowCountOptions = {
apple,2.50 apple,2.50
banana,3.00 banana,3.00
strawberry,1.50`, strawberry,1.50`,
include_header_row: true
}; };
const output: number = czv.rowCount(options); const output: number = czv.rowCount(options);

View file

@ -29,7 +29,7 @@
//! # Links //! # Links
//! //!
//! - czv GitHub repository: <https://github.com/rzmk/czv> //! - czv GitHub repository: <https://github.com/rzmk/czv>
//! - Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) //! - Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) ([docs](https://docs.rs/czv))
//! - WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm)) //! - WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm))
//! - Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python)) //! - Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python))

View file

@ -1,12 +1,12 @@
use czv_wasm; use czv_wasm;
use czv_wasm::count::RowCountOptions; use czv_wasm::count::{ColumnCountOptions, RowCountOptions};
use czv_wasm::Result; use czv_wasm::Result;
use wasm_bindgen_test::*; use wasm_bindgen_test::*;
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[test] #[test]
#[wasm_bindgen_test] #[wasm_bindgen_test]
fn basic() -> Result<()> { fn row_count_nonheader() -> Result<()> {
let options = RowCountOptions { let options = RowCountOptions {
file_data: "fruit,price file_data: "fruit,price
apple,2.00 apple,2.00
@ -19,3 +19,34 @@ strawberry,3.00"
assert_eq!(result, 3); assert_eq!(result, 3);
Ok(()) Ok(())
} }
#[test]
#[wasm_bindgen_test]
fn row_count_header() -> Result<()> {
let options = RowCountOptions {
file_data: "fruit,price
apple,2.00
banana,1.50
strawberry,3.00"
.to_string(),
include_header_row: Some(true),
};
let result = czv_wasm::count::row_count(options)?;
assert_eq!(result, 4);
Ok(())
}
#[test]
#[wasm_bindgen_test]
fn column_count() -> Result<()> {
let options = ColumnCountOptions {
file_data: "fruit,price
apple,2.00
banana,1.50
strawberry,3.00"
.to_string(),
};
let result = czv_wasm::count::column_count(options)?;
assert_eq!(result, 2);
Ok(())
}

View file

@ -5,7 +5,7 @@ Rust library for [czv](https://github.com/rzmk/czv). czv is a library of CSV-rel
## Links ## Links
- czv GitHub repository: <https://github.com/rzmk/czv> - czv GitHub repository: <https://github.com/rzmk/czv>
- Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) - Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) ([docs](https://docs.rs/czv))
- WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm)) - WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm))
- Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python)) - Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python))
@ -67,9 +67,9 @@ For benchmarks we use [criterion.rs](https://github.com/bheisler/criterion.rs).
Licensed under either of Licensed under either of
- Apache License, Version 2.0 - Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) (http://www.apache.org/licenses/LICENSE-2.0)
- MIT license - MIT license
([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) (http://opensource.org/licenses/MIT)
at your option. at your option.

View file

@ -207,6 +207,7 @@ impl<
__file_path: typed_builder::Optional<Option<PathBuf>>, __file_path: typed_builder::Optional<Option<PathBuf>>,
> ColumnCountBuilder<(__file_path, __file_data)> > ColumnCountBuilder<(__file_path, __file_data)>
{ {
/// Returns the column count.
pub fn execute(self) -> Result<usize> { pub fn execute(self) -> Result<usize> {
let builder = self.__build(); let builder = self.__build();
column_count(builder.file_path, builder.file_data) column_count(builder.file_path, builder.file_data)

View file

@ -33,7 +33,7 @@
//! # Links //! # Links
//! //!
//! - czv GitHub repository: <https://github.com/rzmk/czv> //! - czv GitHub repository: <https://github.com/rzmk/czv>
//! - Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) //! - Rust: [crates.io/crates/czv](https://crates.io/crates/czv) ([source code](https://github.com/rzmk/czv/tree/main/czv)) ([docs](https://docs.rs/czv))
//! - WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm)) //! - WebAssembly (JavaScript/TypeScript): [npmjs.com/package/czv-wasm](https://www.npmjs.com/package/czv-wasm) ([source code](https://github.com/rzmk/czv/tree/main/czv-wasm))
//! - Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python)) //! - Python: [pypi.org/project/czv](https://pypi.org/project/czv/) ([source code](https://github.com/rzmk/czv/tree/main/czv-python))
@ -41,7 +41,7 @@
pub mod count; pub mod count;
#[doc(inline)] #[doc(inline)]
pub use count::{ColumnCount, RowCount}; pub use count::{ColumnCount, RowCount};
/// Extract a section of rows. // Extract a section of rows.
// pub mod slice; // pub mod slice;
// #[doc(inline)] // #[doc(inline)]
// pub use slice::Slice; // pub use slice::Slice;