csv-insights 1.0.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.
- csv_insights-1.0.0/LICENSE +21 -0
- csv_insights-1.0.0/PKG-INFO +45 -0
- csv_insights-1.0.0/README.md +36 -0
- csv_insights-1.0.0/csv_insights.egg-info/PKG-INFO +45 -0
- csv_insights-1.0.0/csv_insights.egg-info/SOURCES.txt +12 -0
- csv_insights-1.0.0/csv_insights.egg-info/dependency_links.txt +1 -0
- csv_insights-1.0.0/csv_insights.egg-info/entry_points.txt +2 -0
- csv_insights-1.0.0/csv_insights.egg-info/top_level.txt +1 -0
- csv_insights-1.0.0/csvstat/__init__.py +1 -0
- csv_insights-1.0.0/csvstat/analyzer.py +73 -0
- csv_insights-1.0.0/csvstat/cli.py +25 -0
- csv_insights-1.0.0/pyproject.toml +24 -0
- csv_insights-1.0.0/setup.cfg +4 -0
- csv_insights-1.0.0/tests/test_analyzer.py +127 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Smriti12182004
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: csv-insights
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A Python package for CSV profiling, data analysis, and statistical summaries
|
|
5
|
+
Author: Smriti
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Dynamic: license-file
|
|
9
|
+
|
|
10
|
+
# csvstat-package
|
|
11
|
+
|
|
12
|
+
A lightweight Python package for **CSV profiling and data analysis**.
|
|
13
|
+
`csvstat` helps users quickly understand the structure and content of CSV files by generating useful statistics, detecting data types, and identifying missing values.
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- 📊 **CSV File Profiling**
|
|
18
|
+
- Analyze CSV files and generate a structured summary
|
|
19
|
+
- Get total number of rows and columns
|
|
20
|
+
|
|
21
|
+
- 🔍 **Column Analysis**
|
|
22
|
+
- Automatically detect column data types:
|
|
23
|
+
- Numeric columns
|
|
24
|
+
- Text columns
|
|
25
|
+
- Identify missing values in each column
|
|
26
|
+
|
|
27
|
+
- 📈 **Numeric Statistics**
|
|
28
|
+
- Calculate statistical summaries for numeric columns:
|
|
29
|
+
- Minimum value
|
|
30
|
+
- Maximum value
|
|
31
|
+
- Mean value
|
|
32
|
+
|
|
33
|
+
- 🔤 **Text Analysis**
|
|
34
|
+
- Find the most frequent values in text columns
|
|
35
|
+
- Generate top occurring values with their frequency
|
|
36
|
+
|
|
37
|
+
- 💻 **Command Line Interface**
|
|
38
|
+
- Analyze CSV files directly from the terminal using the `csvstat` command
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
Install `csvstat-package` from PyPI:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install csvstat-package
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# csvstat-package
|
|
2
|
+
|
|
3
|
+
A lightweight Python package for **CSV profiling and data analysis**.
|
|
4
|
+
`csvstat` helps users quickly understand the structure and content of CSV files by generating useful statistics, detecting data types, and identifying missing values.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- 📊 **CSV File Profiling**
|
|
9
|
+
- Analyze CSV files and generate a structured summary
|
|
10
|
+
- Get total number of rows and columns
|
|
11
|
+
|
|
12
|
+
- 🔍 **Column Analysis**
|
|
13
|
+
- Automatically detect column data types:
|
|
14
|
+
- Numeric columns
|
|
15
|
+
- Text columns
|
|
16
|
+
- Identify missing values in each column
|
|
17
|
+
|
|
18
|
+
- 📈 **Numeric Statistics**
|
|
19
|
+
- Calculate statistical summaries for numeric columns:
|
|
20
|
+
- Minimum value
|
|
21
|
+
- Maximum value
|
|
22
|
+
- Mean value
|
|
23
|
+
|
|
24
|
+
- 🔤 **Text Analysis**
|
|
25
|
+
- Find the most frequent values in text columns
|
|
26
|
+
- Generate top occurring values with their frequency
|
|
27
|
+
|
|
28
|
+
- 💻 **Command Line Interface**
|
|
29
|
+
- Analyze CSV files directly from the terminal using the `csvstat` command
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
Install `csvstat-package` from PyPI:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install csvstat-package
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: csv-insights
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A Python package for CSV profiling, data analysis, and statistical summaries
|
|
5
|
+
Author: Smriti
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Dynamic: license-file
|
|
9
|
+
|
|
10
|
+
# csvstat-package
|
|
11
|
+
|
|
12
|
+
A lightweight Python package for **CSV profiling and data analysis**.
|
|
13
|
+
`csvstat` helps users quickly understand the structure and content of CSV files by generating useful statistics, detecting data types, and identifying missing values.
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- 📊 **CSV File Profiling**
|
|
18
|
+
- Analyze CSV files and generate a structured summary
|
|
19
|
+
- Get total number of rows and columns
|
|
20
|
+
|
|
21
|
+
- 🔍 **Column Analysis**
|
|
22
|
+
- Automatically detect column data types:
|
|
23
|
+
- Numeric columns
|
|
24
|
+
- Text columns
|
|
25
|
+
- Identify missing values in each column
|
|
26
|
+
|
|
27
|
+
- 📈 **Numeric Statistics**
|
|
28
|
+
- Calculate statistical summaries for numeric columns:
|
|
29
|
+
- Minimum value
|
|
30
|
+
- Maximum value
|
|
31
|
+
- Mean value
|
|
32
|
+
|
|
33
|
+
- 🔤 **Text Analysis**
|
|
34
|
+
- Find the most frequent values in text columns
|
|
35
|
+
- Generate top occurring values with their frequency
|
|
36
|
+
|
|
37
|
+
- 💻 **Command Line Interface**
|
|
38
|
+
- Analyze CSV files directly from the terminal using the `csvstat` command
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
Install `csvstat-package` from PyPI:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install csvstat-package
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
csv_insights.egg-info/PKG-INFO
|
|
5
|
+
csv_insights.egg-info/SOURCES.txt
|
|
6
|
+
csv_insights.egg-info/dependency_links.txt
|
|
7
|
+
csv_insights.egg-info/entry_points.txt
|
|
8
|
+
csv_insights.egg-info/top_level.txt
|
|
9
|
+
csvstat/__init__.py
|
|
10
|
+
csvstat/analyzer.py
|
|
11
|
+
csvstat/cli.py
|
|
12
|
+
tests/test_analyzer.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
csvstat
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .analyzer import analyze_csv
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import csv
|
|
2
|
+
from collections import Counter
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def analyze_csv(file_path, top=5):
|
|
6
|
+
|
|
7
|
+
with open(file_path, "r") as file:
|
|
8
|
+
reader = csv.reader(file)
|
|
9
|
+
data = list(reader)
|
|
10
|
+
|
|
11
|
+
headers = [header.strip() for header in data[0]]
|
|
12
|
+
rows = data[1:]
|
|
13
|
+
|
|
14
|
+
result = {
|
|
15
|
+
"rows": len(rows),
|
|
16
|
+
"columns": len(headers),
|
|
17
|
+
"column_details": {}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
for i, column in enumerate(headers):
|
|
21
|
+
|
|
22
|
+
values = [
|
|
23
|
+
row[i].strip()
|
|
24
|
+
for row in rows
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
missing = sum(
|
|
28
|
+
1 for value in values
|
|
29
|
+
if value == ""
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
non_missing = [
|
|
33
|
+
value for value in values
|
|
34
|
+
if value != ""
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
is_numeric = True
|
|
38
|
+
|
|
39
|
+
for value in non_missing:
|
|
40
|
+
try:
|
|
41
|
+
float(value)
|
|
42
|
+
except ValueError:
|
|
43
|
+
is_numeric = False
|
|
44
|
+
break
|
|
45
|
+
|
|
46
|
+
if is_numeric and non_missing:
|
|
47
|
+
data_type = "numeric"
|
|
48
|
+
else:
|
|
49
|
+
data_type = "text"
|
|
50
|
+
|
|
51
|
+
details = {
|
|
52
|
+
"type": data_type,
|
|
53
|
+
"missing": missing
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if data_type == "numeric":
|
|
57
|
+
|
|
58
|
+
numeric_values = [
|
|
59
|
+
float(value)
|
|
60
|
+
for value in non_missing
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
details["min"] = min(numeric_values)
|
|
64
|
+
details["mean"] = sum(numeric_values) / len(numeric_values)
|
|
65
|
+
details["max"] = max(numeric_values)
|
|
66
|
+
|
|
67
|
+
else:
|
|
68
|
+
counts = Counter(non_missing)
|
|
69
|
+
details["top_values"] = counts.most_common(top)
|
|
70
|
+
|
|
71
|
+
result["column_details"][column] = details
|
|
72
|
+
|
|
73
|
+
return result
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
from .analyzer import analyze_csv
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def main():
|
|
6
|
+
|
|
7
|
+
parser = argparse.ArgumentParser(
|
|
8
|
+
description="CSV profiling tool"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
parser.add_argument(
|
|
12
|
+
"file",
|
|
13
|
+
help="Path to CSV file"
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
args = parser.parse_args()
|
|
17
|
+
|
|
18
|
+
result = analyze_csv(args.file)
|
|
19
|
+
|
|
20
|
+
print("Rows:", result["rows"])
|
|
21
|
+
print("Columns:", result["columns"])
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
if __name__ == "__main__":
|
|
25
|
+
main()
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
[project]
|
|
7
|
+
name = "csv-insights"
|
|
8
|
+
version = "1.0.0"
|
|
9
|
+
description = "A Python package for CSV profiling, data analysis, and statistical summaries"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Smriti"}
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
dependencies = []
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
[project.scripts]
|
|
20
|
+
csvstat = "csvstat.cli:main"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
[tool.setuptools.packages.find]
|
|
24
|
+
include = ["csvstat*"]
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from csvstat import analyze_csv
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@pytest.fixture
|
|
6
|
+
def csv_result():
|
|
7
|
+
result = analyze_csv("data/sample.csv")
|
|
8
|
+
return result
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_row_count(csv_result):
|
|
12
|
+
assert csv_result["rows"] == 4
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_column_count(csv_result):
|
|
16
|
+
assert csv_result["columns"] == 2
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def test_numeric_column_detection(csv_result):
|
|
20
|
+
assert csv_result["column_details"]["Age"]["type"] == "numeric"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_text_column_detection(csv_result):
|
|
24
|
+
assert csv_result["column_details"]["Name"]["type"] == "text"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_missing_values(csv_result):
|
|
28
|
+
assert csv_result["column_details"]["Age"]["missing"] == 0
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_numeric_statistics(csv_result):
|
|
32
|
+
age_details = csv_result["column_details"]["Age"]
|
|
33
|
+
|
|
34
|
+
assert age_details["min"] == 25
|
|
35
|
+
assert age_details["max"] == 35
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# New test cases
|
|
39
|
+
|
|
40
|
+
def test_numeric_mean(csv_result):
|
|
41
|
+
age_details = csv_result["column_details"]["Age"]
|
|
42
|
+
|
|
43
|
+
assert age_details["mean"] == 29.5
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_text_top_values(csv_result):
|
|
47
|
+
name_details = csv_result["column_details"]["Name"]
|
|
48
|
+
|
|
49
|
+
assert "top_values" in name_details
|
|
50
|
+
assert len(name_details["top_values"]) > 0
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_column_details_exist(csv_result):
|
|
54
|
+
assert "Name" in csv_result["column_details"]
|
|
55
|
+
assert "Age" in csv_result["column_details"]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_result_structure(csv_result):
|
|
59
|
+
assert "rows" in csv_result
|
|
60
|
+
assert "columns" in csv_result
|
|
61
|
+
assert "column_details" in csv_result
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def test_numeric_min_less_than_max(csv_result):
|
|
65
|
+
age_details = csv_result["column_details"]["Age"]
|
|
66
|
+
|
|
67
|
+
assert age_details["min"] < age_details["max"]
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def test_numeric_values_are_correct_type(csv_result):
|
|
71
|
+
age_details = csv_result["column_details"]["Age"]
|
|
72
|
+
|
|
73
|
+
assert isinstance(age_details["min"], float)
|
|
74
|
+
assert isinstance(age_details["max"], float)
|
|
75
|
+
|
|
76
|
+
def test_default_top_values_limit(csv_result):
|
|
77
|
+
name_details = csv_result["column_details"]["Name"]
|
|
78
|
+
|
|
79
|
+
assert len(name_details["top_values"]) <= 5
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def test_rows_value_is_integer(csv_result):
|
|
83
|
+
assert isinstance(csv_result["rows"], int)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def test_columns_value_is_integer(csv_result):
|
|
87
|
+
assert isinstance(csv_result["columns"], int)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def test_column_details_is_dictionary(csv_result):
|
|
91
|
+
assert isinstance(csv_result["column_details"], dict)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_age_details_contains_required_fields(csv_result):
|
|
95
|
+
age_details = csv_result["column_details"]["Age"]
|
|
96
|
+
|
|
97
|
+
assert "type" in age_details
|
|
98
|
+
assert "missing" in age_details
|
|
99
|
+
assert "min" in age_details
|
|
100
|
+
assert "max" in age_details
|
|
101
|
+
assert "mean" in age_details
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def test_name_details_contains_required_fields(csv_result):
|
|
105
|
+
name_details = csv_result["column_details"]["Name"]
|
|
106
|
+
|
|
107
|
+
assert "type" in name_details
|
|
108
|
+
assert "missing" in name_details
|
|
109
|
+
assert "top_values" in name_details
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def test_no_missing_values_in_name(csv_result):
|
|
113
|
+
assert csv_result["column_details"]["Name"]["missing"] == 0
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def test_numeric_mean_between_min_max(csv_result):
|
|
117
|
+
age_details = csv_result["column_details"]["Age"]
|
|
118
|
+
|
|
119
|
+
assert age_details["min"] <= age_details["mean"] <= age_details["max"]
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def test_age_type_not_text(csv_result):
|
|
123
|
+
assert csv_result["column_details"]["Age"]["type"] != "text"
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def test_name_type_not_numeric(csv_result):
|
|
127
|
+
assert csv_result["column_details"]["Name"]["type"] != "numeric"
|