csvsmith 0.12.0__tar.gz → 0.13.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {csvsmith-0.12.0/src/csvsmith.egg-info → csvsmith-0.13.0}/PKG-INFO +2 -24
- {csvsmith-0.12.0 → csvsmith-0.13.0}/pyproject.toml +4 -4
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/__init__.py +6 -1
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/tools/csv_viewer.py +23 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0/src/csvsmith.egg-info}/PKG-INFO +2 -24
- {csvsmith-0.12.0 → csvsmith-0.13.0}/tests/test_cli.py +8 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/tests/test_csv_viewer.py +52 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/LICENSE +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/README.rst +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/setup.cfg +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/cli.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/tools/__init__.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/tools/classify.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/tools/dense_csv.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/tools/excel2csv.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/tools/filter_rows.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/tools/find_matches_in_csv.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/tools/knapsack_csv.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/tools/move_files.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/tools/row_dedup.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/tools/sample_csv.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/tools/strict_concat.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/tools/strip_bom.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/utils/__init__.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/utils/clean_numeric.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/utils/distance.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/utils/io.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith/utils/normalize.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith.egg-info/SOURCES.txt +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith.egg-info/dependency_links.txt +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith.egg-info/entry_points.txt +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith.egg-info/requires.txt +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/src/csvsmith.egg-info/top_level.txt +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/tests/test_classify.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/tests/test_clean_numeric.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/tests/test_dense_csv.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/tests/test_excel2csv.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/tests/test_filter_rows.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/tests/test_find_matches_in_csv.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/tests/test_knapsack_csv.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/tests/test_move_files.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/tests/test_normalize.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/tests/test_row_dedup.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/tests/test_sample_csv.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/tests/test_strict_concat.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/tests/test_string_distance.py +0 -0
- {csvsmith-0.12.0 → csvsmith-0.13.0}/tests/test_strip_bom.py +0 -0
|
@@ -1,37 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: csvsmith
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0
|
|
4
4
|
Summary: Small CSV utilities: row deduplication, classification, row filtering, and CLI helpers.
|
|
5
5
|
Author-email: Eiichi YAMAMOTO <info@yeiichi.com>
|
|
6
|
-
License: MIT
|
|
7
|
-
|
|
8
|
-
Copyright (c) 2026 Eiichi YAMAMOTO
|
|
9
|
-
|
|
10
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
-
in the Software without restriction, including without limitation the rights
|
|
13
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
-
furnished to do so, subject to the following conditions:
|
|
16
|
-
|
|
17
|
-
The above copyright notice and this permission notice shall be included in
|
|
18
|
-
all copies or substantial portions of the Software.
|
|
19
|
-
|
|
20
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
25
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
26
|
-
IN THE SOFTWARE.
|
|
27
|
-
|
|
6
|
+
License-Expression: MIT
|
|
28
7
|
Project-URL: Homepage, https://github.com/yeiichi/csvsmith
|
|
29
8
|
Project-URL: Repository, https://github.com/yeiichi/csvsmith
|
|
30
9
|
Project-URL: Documentation, https://csvsmith.readthedocs.io/en/latest/
|
|
31
10
|
Keywords: csv,deduplication,data-filtering,file-organization,filtering
|
|
32
11
|
Classifier: Programming Language :: Python :: 3
|
|
33
12
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
34
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
35
13
|
Classifier: Intended Audience :: Developers
|
|
36
14
|
Classifier: Topic :: Software Development :: Libraries
|
|
37
15
|
Classifier: Topic :: Utilities
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["setuptools>=
|
|
2
|
+
requires = ["setuptools>=77.0", "wheel"]
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "csvsmith"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.13.0"
|
|
8
8
|
description = "Small CSV utilities: row deduplication, classification, row filtering, and CLI helpers."
|
|
9
9
|
readme = "README.rst"
|
|
10
10
|
requires-python = ">=3.10"
|
|
11
|
-
license =
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
12
13
|
|
|
13
14
|
authors = [
|
|
14
15
|
{ name = "Eiichi YAMAMOTO", email = "info@yeiichi.com" }
|
|
@@ -25,7 +26,6 @@ keywords = [
|
|
|
25
26
|
classifiers = [
|
|
26
27
|
"Programming Language :: Python :: 3",
|
|
27
28
|
"Programming Language :: Python :: 3 :: Only",
|
|
28
|
-
"License :: OSI Approved :: MIT License",
|
|
29
29
|
"Intended Audience :: Developers",
|
|
30
30
|
"Topic :: Software Development :: Libraries",
|
|
31
31
|
"Topic :: Utilities",
|
|
@@ -43,7 +43,12 @@ Submodules:
|
|
|
43
43
|
- csvsmith.cli (CLI entrypoint)
|
|
44
44
|
"""
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
47
|
+
|
|
48
|
+
try:
|
|
49
|
+
__version__ = version("csvsmith")
|
|
50
|
+
except PackageNotFoundError:
|
|
51
|
+
__version__ = "0.0.0"
|
|
47
52
|
|
|
48
53
|
from .tools.classify import CSVClassifier
|
|
49
54
|
from .tools.csv_viewer import DataFrame, build_filter, infer_type
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import csv
|
|
4
|
+
import io
|
|
4
5
|
import operator
|
|
5
6
|
from pathlib import Path
|
|
6
7
|
from typing import Any, Callable, TextIO
|
|
@@ -88,6 +89,28 @@ class DataFrame:
|
|
|
88
89
|
"""Return the first ``n`` rows formatted as a text table."""
|
|
89
90
|
return self.render(end=n)
|
|
90
91
|
|
|
92
|
+
def to_csv(
|
|
93
|
+
self,
|
|
94
|
+
filepath: str | Path | None = None,
|
|
95
|
+
*,
|
|
96
|
+
encoding: str = "utf-8",
|
|
97
|
+
) -> str | Path:
|
|
98
|
+
"""Return the ``DataFrame`` as CSV, or write it to ``filepath``."""
|
|
99
|
+
output = io.StringIO()
|
|
100
|
+
writer = csv.writer(output)
|
|
101
|
+
writer.writerow(self.columns)
|
|
102
|
+
for index in range(len(self)):
|
|
103
|
+
writer.writerow([self._data[column][index] for column in self.columns])
|
|
104
|
+
csv_text = output.getvalue()
|
|
105
|
+
|
|
106
|
+
if filepath is None:
|
|
107
|
+
return csv_text
|
|
108
|
+
|
|
109
|
+
path = Path(filepath)
|
|
110
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
111
|
+
path.write_text(csv_text, encoding=encoding, newline="")
|
|
112
|
+
return path
|
|
113
|
+
|
|
91
114
|
def select(self, columns: list[str]) -> DataFrame:
|
|
92
115
|
"""Return a new ``DataFrame`` with the selected columns."""
|
|
93
116
|
missing = [column for column in columns if column not in self._data]
|
|
@@ -1,37 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: csvsmith
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0
|
|
4
4
|
Summary: Small CSV utilities: row deduplication, classification, row filtering, and CLI helpers.
|
|
5
5
|
Author-email: Eiichi YAMAMOTO <info@yeiichi.com>
|
|
6
|
-
License: MIT
|
|
7
|
-
|
|
8
|
-
Copyright (c) 2026 Eiichi YAMAMOTO
|
|
9
|
-
|
|
10
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
-
in the Software without restriction, including without limitation the rights
|
|
13
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
-
furnished to do so, subject to the following conditions:
|
|
16
|
-
|
|
17
|
-
The above copyright notice and this permission notice shall be included in
|
|
18
|
-
all copies or substantial portions of the Software.
|
|
19
|
-
|
|
20
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
25
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
26
|
-
IN THE SOFTWARE.
|
|
27
|
-
|
|
6
|
+
License-Expression: MIT
|
|
28
7
|
Project-URL: Homepage, https://github.com/yeiichi/csvsmith
|
|
29
8
|
Project-URL: Repository, https://github.com/yeiichi/csvsmith
|
|
30
9
|
Project-URL: Documentation, https://csvsmith.readthedocs.io/en/latest/
|
|
31
10
|
Keywords: csv,deduplication,data-filtering,file-organization,filtering
|
|
32
11
|
Classifier: Programming Language :: Python :: 3
|
|
33
12
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
34
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
35
13
|
Classifier: Intended Audience :: Developers
|
|
36
14
|
Classifier: Topic :: Software Development :: Libraries
|
|
37
15
|
Classifier: Topic :: Utilities
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
from importlib.metadata import version
|
|
2
|
+
|
|
1
3
|
import pytest
|
|
4
|
+
|
|
5
|
+
import csvsmith
|
|
2
6
|
from csvsmith.cli import build_parser, main
|
|
3
7
|
|
|
4
8
|
|
|
9
|
+
def test_package_version_matches_metadata():
|
|
10
|
+
assert csvsmith.__version__ == version("csvsmith")
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
def test_main_help():
|
|
6
14
|
with pytest.raises(SystemExit) as excinfo:
|
|
7
15
|
main(["--help"])
|
|
@@ -70,6 +70,58 @@ def test_dataframe_filter_supports_numeric_comparisons(tmp_path):
|
|
|
70
70
|
assert df["name"] == ["Alice"]
|
|
71
71
|
|
|
72
72
|
|
|
73
|
+
def test_dataframe_to_csv_returns_csv_string(tmp_path):
|
|
74
|
+
source = tmp_path / "sample.csv"
|
|
75
|
+
write_csv(
|
|
76
|
+
source,
|
|
77
|
+
[
|
|
78
|
+
["name", "score", "note"],
|
|
79
|
+
["Alice", "10", "Hello, Tokyo"],
|
|
80
|
+
["Bob", "8", "Line\nbreak"],
|
|
81
|
+
],
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
df = DataFrame.from_csv(source).filter(build_filter("score", ">", "7"))
|
|
85
|
+
|
|
86
|
+
assert (
|
|
87
|
+
df.to_csv()
|
|
88
|
+
== 'name,score,note\r\nAlice,10,"Hello, Tokyo"\r\nBob,8,"Line\nbreak"\r\n'
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_dataframe_to_csv_writes_csv_file(tmp_path):
|
|
93
|
+
source = tmp_path / "sample.csv"
|
|
94
|
+
output = tmp_path / "exports" / "filtered.csv"
|
|
95
|
+
write_csv(
|
|
96
|
+
source,
|
|
97
|
+
[
|
|
98
|
+
["name", "score", "note"],
|
|
99
|
+
["Alice", "10", "Hello, Tokyo"],
|
|
100
|
+
["Bob", "8", "Line\nbreak"],
|
|
101
|
+
],
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
df = DataFrame.from_csv(source).filter(build_filter("score", ">", "8"))
|
|
105
|
+
|
|
106
|
+
result = df.to_csv(output)
|
|
107
|
+
|
|
108
|
+
assert result == output
|
|
109
|
+
assert output.read_text(encoding="utf-8") == "name,score,note\nAlice,10,\"Hello, Tokyo\"\n"
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def test_dataframe_to_csv_round_trips_with_from_csv(tmp_path):
|
|
113
|
+
source = tmp_path / "sample.csv"
|
|
114
|
+
output = tmp_path / "output.csv"
|
|
115
|
+
write_csv(source, [["id", "name"], ["001", "Alice"], ["002", "Bob"]])
|
|
116
|
+
|
|
117
|
+
DataFrame.from_csv(source, convert_types=False).to_csv(output)
|
|
118
|
+
|
|
119
|
+
round_tripped = DataFrame.from_csv(output, convert_types=False)
|
|
120
|
+
assert round_tripped.columns == ["id", "name"]
|
|
121
|
+
assert round_tripped["id"] == ["001", "002"]
|
|
122
|
+
assert round_tripped["name"] == ["Alice", "Bob"]
|
|
123
|
+
|
|
124
|
+
|
|
73
125
|
def test_view_command_filters_and_selects_columns(tmp_path, capsys):
|
|
74
126
|
source = tmp_path / "sample.csv"
|
|
75
127
|
write_csv(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|