Skip to content

Commit

Permalink
renamed the pcakage
Browse files Browse the repository at this point in the history
renamed the package to be compatible to pypi
  • Loading branch information
Khaleelhabeeb committed Apr 5, 2024
1 parent 2661b14 commit 44a48b4
Show file tree
Hide file tree
Showing 20 changed files with 62 additions and 28 deletions.
7 changes: 7 additions & 0 deletions csv_utilite/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from .reader import Reader
from .writer import Writer
from .validation import validate_rows, validate_headers
from .conversion import csv_to_json, json_to_csv
from .manipulation import filter_rows, sort_rows, merge_files
from .generation import generate_from_db, generate_from_dict
from .formating import quote_fields, remove_quotes, handle_newlines
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file removed csv_utils/__init__.py
Empty file.
Empty file removed main.py
Empty file.
43 changes: 22 additions & 21 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# CSV-UTILS DOCUMENTATION
# CSV-UTILITE DOCUMENTATION

csv-util is a Python package designed to facilitate working with CSV files in a more convenient and Pythonic manner compared to the built-in csv module. It provides a set of modules with classes and functions to perform various tasks related to CSV file handling.
csv-utilite is a Python package designed to facilitate working with CSV files in a more convenient and Pythonic manner compared to the built-in csv module. It provides a set of modules with classes and functions to perform various tasks related to CSV file handling.

## Installation

You can install csv-util via pip:
You can install csv-utilite via pip:

```pip install csv-utils ```
```pip install csv_utilite ```

## CORE MODULES

### Reader

This module contains the Reader class, which extends the functionality of csv.reader. It offers additional features such as automatic type casting, handling missing values, and support for different dialects.

``` from csv_util.reader import Reader ```
``` from csv_utilite.reader import Reader ```

### Example usage
```python
from csv_utils.reader import Reader
from csv_utilite.reader import Reader

with open('kano.csv', 'r') as file:
reader = Reader(file, dialect='excel', type_cast=True, na_values=['', 'NULL'])
Expand All @@ -32,11 +32,11 @@ with open('kano.csv', 'r') as file:

The writer.py module includes the Writer class, a subclass of csv.writer, enhanced with features like automatic type casting and support for different dialects.

``` from csv_util.writer import Writer ```
``` from csv_utilite.writer import Writer ```

### Example usage
```python
from csv_utils.writer import Writer
from csv_utilite.writer import Writer
with open('output.csv', 'w', newline='') as file:
writer = Writer(file, dialect='excel', na_rep='NA')
writer.writerow([1, 2.5, True, None, 'abc'])
Expand All @@ -50,11 +50,11 @@ with open('output.csv', 'w', newline='') as file:
This module provides functions for common operations on CSV data, such as filtering rows, sorting, merging multiple files, and handling headers.


``` from csv_util.manipulation import filter_rows, sort_rows ```
``` from csv_utilite.manipulation import filter_rows, sort_rows ```

### Example usage
```python
from csv_utils.manipulation import filter_rows, sort_rows, merge_files
from csv_utilite.manipulation import filter_rows, sort_rows, merge_files
# Filter rows
data = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
filtered_data = filter_rows(data, lambda row: sum(row) > 10)
Expand All @@ -76,13 +76,13 @@ merge_files(file_paths, output_path, dialect='excel', has_header=True)
formatting.py includes functions for formatting CSV data, such as adding or removing quotes, handling newlines within fields, and customizing delimiters.


``` from csv_util.formatting import add_quotes, remove_quotes ```
``` from csv_utilite.formatting import add_quotes, remove_quotes ```

### Example usage

```python
import csv
from csv_utils.formating import quote_fields, remove_quotes, handle_newlines
from csv_utilite.formating import quote_fields, remove_quotes, handle_newlines

# Quote fields
data = [['Name', 'Age', 'City'], ['John', 25, 'New York'], ['Jane', 30, 'London, UK']]
Expand All @@ -106,12 +106,12 @@ print(formatted_data) # Output: [['Name', 'Address'], ['John', '123 Main St. Ne

The validation.py module provides functions to validate CSV data against predefined rules or schemas, ensuring data integrity and consistency.

``` from csv_util.validation import validate_schema ```
``` from csv_utilite.validation import validate_schema ```

### Example usage

```python
from csv_utils.validation import validate_rows, validate_headers
from csv_utilite.validation import validate_rows, validate_headers
# Validate rows
data = [[1, 2, 3], [4, 'five', 6], [7, 8, 'nine']]
validators = {
Expand All @@ -136,12 +136,13 @@ print(is_valid) # Output: True
This module contains functions to convert CSV data to and from other formats like JSON, Excel, SQL tables, etc.


``` from csv_util.conversion import csv_to_json, json_to_csv ```
``` from csv_utilite.conversion import csv_to_json, json_to_csv ```

### Example usage

```pyhton
from csv_utils.conversion import csv_to_json, json_to_csv
```python

from csv_utilite.conversion import csv_to_json, json_to_csv
# CSV to JSON
data = [['Name', 'Age', 'City'], ['John', 25, 'New York'], ['Jane', 30, 'London']]
json_data = csv_to_json(data[1:], headers=data[0], orient='records')
Expand All @@ -159,15 +160,15 @@ print(csv_data) # Output: [['Name', 'Age', 'City'], ['John', 25, 'New York'], [
The generation.py module includes functions to generate CSV files from various data sources, such as dictionaries, databases, or APIs.


from csv_util.generation import generate_from_dict
from csv_utilite.generation import generate_from_dict

# Example usage

``` from csv_utils.generation import generate_from_db, generate_from_dict ```
``` from csv_utilite.generation import generate_from_db, generate_from_dict ```

```python

from csv_utils.generation import generate_from_db, generate_from_dict
from csv_utilite.generation import generate_from_db, generate_from_dict

# Generate CSV from a dictionary
data = {'Name': 'John', 'Age': 25, 'City': 'New York'}
Expand All @@ -194,4 +195,4 @@ All meaningful contributions are welcome.
We appreciate any improvements, bug fixes, or new features you can contribute to this project. Feel free to fork this repository, make your changes, and submit a pull request.

# Conclusion
csv-util simplifies CSV file handling in Python by providing a comprehensive set of classes and functions for reading, writing, manipulating, formatting, validating, converting, and generating CSV data. With its intuitive API and enhanced features, csv-util is a valuable tool for data processing tasks involving CSV files.
csv-utilite simplifies CSV file handling in Python by providing a comprehensive set of classes and functions for reading, writing, manipulating, formatting, validating, converting, and generating CSV data. With its intuitive API and enhanced features, csv-util is a valuable tool for data processing tasks involving CSV files.
Binary file modified requirements.txt
Binary file not shown.
26 changes: 26 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from setuptools import setup, find_packages

setup(
name='csv_utilite',
version='1.0.0',
description='csv-util is a Python package designed to facilitate working with CSV files in a more convenient and Pythonic manner compared to the built-in csv module.',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
author='Khalil Habib Shariff',
author_email='[email protected]',
packages=find_packages(),
install_requires=[

],
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
],
)
2 changes: 1 addition & 1 deletion test/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Iterable, Any, Union, List, Dict, Optional
import csv
import json
from csv_utils.conversion import csv_to_json, json_to_csv
from csv_utilite.conversion import csv_to_json, json_to_csv

class CSVUtilsTest(unittest.TestCase):

Expand Down
2 changes: 1 addition & 1 deletion test/test_formating.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from unittest.mock import patch
from typing import Iterable, Any, List, Optional
import csv
from csv_utils.formating import quote_fields, remove_quotes, handle_newlines
from csv_utilite.formating import quote_fields, remove_quotes, handle_newlines


class CSVUtilsTest(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion test/test_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import tempfile
from unittest.mock import patch, MagicMock
from csv_utils.generation import generate_from_dict, generate_from_db
from csv_utilities.generation import generate_from_dict, generate_from_db

class TestGenerationModule(unittest.TestCase):
def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion test/test_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import csv
from unittest.mock import patch, MagicMock
from typing import Iterable, Any, Callable, List, Dict, Optional
from csv_utils.manipulation import filter_rows, sort_rows, merge_files
from csv_utilities.manipulation import filter_rows, sort_rows, merge_files

class CSVUtilsTest(unittest.TestCase):

Expand Down
2 changes: 1 addition & 1 deletion test/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from unittest.mock import patch, MagicMock
import csv
from typing import Iterator, Optional, Any, Union, List, Dict
from reader import Reader
from csv_utilities.reader import Reader

class Reader(Reader):
"""
Expand Down
2 changes: 1 addition & 1 deletion test/test_validation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
from unittest.mock import patch, MagicMock
from typing import Iterable, Any, Callable, List, Dict, Optional
from csv_utils.validation import validate_rows, validate_headers
from csv_utilities.validation import validate_rows, validate_headers

class CSVUtilsTest(unittest.TestCase):

Expand Down
2 changes: 1 addition & 1 deletion test/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from unittest.mock import patch, MagicMock
import csv
from typing import Iterable, Any, Union, Optional
from csv_utils.writer import Writer
from csv_utilities.writer import Writer


class Writer(Writer):
Expand Down

0 comments on commit 44a48b4

Please sign in to comment.