csvhelper 0.1.0__py3-none-any.whl
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.
- csvhelper-0.1.0.dist-info/METADATA +55 -0
- csvhelper-0.1.0.dist-info/RECORD +9 -0
- csvhelper-0.1.0.dist-info/WHEEL +5 -0
- csvhelper-0.1.0.dist-info/licenses/LICENSE +21 -0
- csvhelper-0.1.0.dist-info/top_level.txt +3 -0
- csvtoolkit/__init__.py +1 -0
- csvtoolkit/csv_utils.py +61 -0
- examples/eg.py +10 -0
- tests/test_csv.py +14 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: csvhelper
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A simple Python library for CSV cleaning and manipulation.
|
|
5
|
+
Author: Muthu Kumar
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: pandas
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# CSV Toolkit
|
|
14
|
+
|
|
15
|
+
A simple and beginner-friendly Python library for CSV cleaning and manipulation built using Pandas.
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- Read CSV files
|
|
20
|
+
- Display the dataset
|
|
21
|
+
- Show first rows
|
|
22
|
+
- Show last rows
|
|
23
|
+
- View column names
|
|
24
|
+
- Get dataset shape
|
|
25
|
+
- Count rows
|
|
26
|
+
- Find missing values
|
|
27
|
+
- Remove duplicate rows
|
|
28
|
+
- Remove empty rows
|
|
29
|
+
- Fill missing values
|
|
30
|
+
- Rename columns
|
|
31
|
+
- Sort data
|
|
32
|
+
- Save cleaned CSV files
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install csv-toolkit
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Example
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from csvtoolkit import CSVToolkit
|
|
44
|
+
|
|
45
|
+
csv = CSVToolkit("employees.csv")
|
|
46
|
+
|
|
47
|
+
csv.show()
|
|
48
|
+
csv.remove_duplicates()
|
|
49
|
+
csv.remove_empty_rows()
|
|
50
|
+
csv.save("clean.csv")
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
MIT License
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
csvhelper-0.1.0.dist-info/licenses/LICENSE,sha256=6b4j7JC2jBx8hNBjFO7Gr7_qczJ_euk4KbhG-RQJ-oI,1067
|
|
2
|
+
csvtoolkit/__init__.py,sha256=EGBlaZRnSJnvZmJ7zekcSdFgPCvLSFIrQ6ZOQ_rhok8,34
|
|
3
|
+
csvtoolkit/csv_utils.py,sha256=5e4VAU668zU0pP8Cf4_TMhtV6i_deC2UX8Hbna9hvm0,1326
|
|
4
|
+
examples/eg.py,sha256=l9lZwC1-uOa5W8K0r-kkhAroyKUj2d8OVEjOLJhqdvA,210
|
|
5
|
+
tests/test_csv.py,sha256=-uddUTsNcbF_11x5bXc0_y9OVBSQa5FGjbmSRkLqrdA,397
|
|
6
|
+
csvhelper-0.1.0.dist-info/METADATA,sha256=MFL6rR3WY5OgDyKqReapC5tRTOh8l3haVLDjrnPWZtc,939
|
|
7
|
+
csvhelper-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
8
|
+
csvhelper-0.1.0.dist-info/top_level.txt,sha256=wwAxXDjUoqmRe76Tul2HwthqZglCf-S10rbr9ZTUeqQ,26
|
|
9
|
+
csvhelper-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Muthu Kumar
|
|
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.
|
csvtoolkit/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .csv_utils import CSVToolkit
|
csvtoolkit/csv_utils.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
|
|
3
|
+
class CSVToolkit :
|
|
4
|
+
|
|
5
|
+
def __init__(self, file_path):
|
|
6
|
+
self.file_path = file_path
|
|
7
|
+
self.df = pd.read_csv(file_path)
|
|
8
|
+
|
|
9
|
+
def show(self):
|
|
10
|
+
print(self.df)
|
|
11
|
+
|
|
12
|
+
def head(self, rows=5):
|
|
13
|
+
print(self.df.head(rows))
|
|
14
|
+
|
|
15
|
+
def tail(self, rows=5):
|
|
16
|
+
return self.df.tail(rows)
|
|
17
|
+
|
|
18
|
+
def columns(self):
|
|
19
|
+
return self.df.columns.to_list()
|
|
20
|
+
|
|
21
|
+
def remove_duplicates(self):
|
|
22
|
+
self.df = self.df.drop_duplicates()
|
|
23
|
+
return self.df
|
|
24
|
+
|
|
25
|
+
def remove_empty_rows(self):
|
|
26
|
+
self.df = self.df.dropna()
|
|
27
|
+
return self.df
|
|
28
|
+
|
|
29
|
+
def save(self, output_file):
|
|
30
|
+
self.df.to_csv(output_file, index=False)
|
|
31
|
+
|
|
32
|
+
def shape(self):
|
|
33
|
+
return self.df.shape
|
|
34
|
+
|
|
35
|
+
def row_count(self):
|
|
36
|
+
return len(self.df)
|
|
37
|
+
|
|
38
|
+
def column_count(self):
|
|
39
|
+
return len(self.df.columns)
|
|
40
|
+
|
|
41
|
+
def missing_values(self):
|
|
42
|
+
return self.df.isnull().sum()
|
|
43
|
+
|
|
44
|
+
def info(self):
|
|
45
|
+
self.df.info()
|
|
46
|
+
|
|
47
|
+
def fill_missing(self, value):
|
|
48
|
+
self.df = self.df.fillna(value)
|
|
49
|
+
return self.df
|
|
50
|
+
|
|
51
|
+
def rename_columns(self, mapping):
|
|
52
|
+
self.df = self.df.rename(columns=mapping)
|
|
53
|
+
return self.df
|
|
54
|
+
|
|
55
|
+
def sort_by(self, column, ascending=True):
|
|
56
|
+
self.df = self.df.sort_values(by=column, ascending=ascending)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
examples/eg.py
ADDED
tests/test_csv.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from csvtoolkit import CSVToolkit
|
|
2
|
+
|
|
3
|
+
def test_columns():
|
|
4
|
+
csv = CSVToolkit("examples/employees.csv")
|
|
5
|
+
assert csv.columns() == ["Name", "Age", "Department"]
|
|
6
|
+
|
|
7
|
+
def test_shape():
|
|
8
|
+
csv = CSVToolkit("examples/employees.csv")
|
|
9
|
+
assert csv.shape() == (5, 3)
|
|
10
|
+
|
|
11
|
+
def test_remove_duplicates():
|
|
12
|
+
csv = CSVToolkit("examples/employees.csv")
|
|
13
|
+
csv.remove_duplicates()
|
|
14
|
+
assert csv.shape() == (4, 3)
|