-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8dab3b
commit eefb4c4
Showing
31 changed files
with
1,437 additions
and
105 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# Data Import Documentation | ||
|
||
## Overview | ||
|
||
The Data Import module of the DataAnalysisToolkit provides functionalities to import data from various sources such as Excel files, SQL databases, and APIs. It is designed to simplify the process of data collection and integration for analysis and machine learning tasks. | ||
|
||
## Features | ||
|
||
- **Excel Connector**: Import data from Excel files (.xlsx, .xls). | ||
- **SQL Connector**: Connect and import data from SQL databases like MySQL, PostgreSQL, etc. | ||
- **API Connector**: Fetch data from various APIs with handling for authentication and rate-limiting. | ||
- **Data Integrator**: Merge or concatenate data from different sources into a unified DataFrame. | ||
- **Data Formatter**: Standardize and transform the imported data into a consistent format. | ||
|
||
## Getting Started | ||
|
||
### Excel Connector | ||
|
||
To import data from Excel files: | ||
|
||
```python | ||
from data_sources.excel_connector import ExcelConnector | ||
|
||
connector = ExcelConnector('path/to/excel/file.xlsx') | ||
data = connector.load_data(sheet_name='Sheet1') | ||
``` | ||
|
||
### SQL Connector | ||
|
||
For SQL databases: | ||
|
||
```python | ||
from data_sources.sql_connector import SQLConnector | ||
|
||
connector = SQLConnector('database_URI') | ||
data = connector.query_data('SELECT * FROM table_name') | ||
``` | ||
|
||
### API Connector | ||
|
||
To fetch data from an API: | ||
|
||
```python | ||
from data_sources.api_connector import APIConnector | ||
|
||
connector = APIConnector('https://api.example.com', auth=('username', 'password')) | ||
response = connector.get('endpoint') | ||
``` | ||
|
||
### Data Integrator | ||
|
||
Merge or concatenate data from multiple sources: | ||
|
||
```python | ||
from integrators.data_integrator import DataIntegrator | ||
|
||
integrator = DataIntegrator() | ||
integrator.add_data(data_from_excel) | ||
integrator.add_data(data_from_sql) | ||
combined_data = integrator.concatenate_data() | ||
``` | ||
|
||
### Data Formatter | ||
|
||
Standardize or transform the data: | ||
|
||
```python | ||
from formatters.data_formatter import DataFormatter | ||
|
||
formatter = DataFormatter(combined_data) | ||
formatter.standardize_dates('date_column') | ||
formatter.normalize_numeric(['numeric_column']) | ||
``` | ||
|
||
## Error Handling | ||
|
||
The toolkit includes error handling for common issues encountered during data import, such as file not found, invalid format, or connection issues. Ensure to handle exceptions in your implementation to maintain robustness. | ||
|
||
## Examples | ||
|
||
Refer to the `examples` directory for detailed examples of using each connector and integrating data from multiple sources. | ||
|
||
## Contribution | ||
|
||
Contributions to enhance the data import module, such as adding new connectors or improving existing functionalities, are welcome. Please refer to the contribution guidelines for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" | |
|
||
[project] | ||
name = "dataanalysistoolkit" | ||
version = "1.0.1" | ||
version = "1.1.0" | ||
description = "The `DataAnalysisToolkit` project is a Python-based data analysis tool designed to streamline various data analysis tasks. It allows users to load data from CSV files and perform operations such as statistical calculations, outlier detection, data cleaning, and visualization." | ||
authors = [ | ||
{ name = "Thaddeus Thomas", email = "[email protected]" } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,10 @@ scipy | |
scikit-learn | ||
pandas | ||
matplotlib | ||
seaborn | ||
pytest | ||
nltk | ||
requests | ||
sqlalchemy | ||
pytest-mock | ||
openpyxl |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
"""api_connector.py | ||
_summary_ | ||
_extended_summary_ | ||
Returns: | ||
_type_: _description_ | ||
# Example usage | ||
connector = APIConnector('https://api.example.com', auth=('username', 'password')) | ||
response = connector.get('endpoint', params={'key': 'value'}) | ||
update_response = connector.put('endpoint', json={'key': 'updated_value'}) | ||
delete_response = connector.delete('endpoint', params={'key': 'value'}) | ||
patch_response = connector.patch('endpoint', json={'key': 'new_value'}) | ||
print(response.json()) | ||
""" | ||
|
||
import requests | ||
|
||
class APIConnector: | ||
""" | ||
_summary_ | ||
_extended_summary_ | ||
""" | ||
def __init__(self, base_url, auth=None): | ||
""" | ||
Initialize the APIConnector with the base URL and optional authentication. | ||
Args: | ||
base_url (str): The base URL for the API. | ||
auth (tuple, optional): A tuple for authentication, typically (username, password) or an API token. | ||
""" | ||
self.base_url = base_url | ||
self.auth = auth | ||
self.session = requests.Session() | ||
if auth: | ||
self.session.auth = auth | ||
|
||
def get(self, endpoint, params=None): | ||
""" | ||
Send a GET request to the API. | ||
Args: | ||
endpoint (str): The API endpoint to send the request to. | ||
params (dict, optional): A dictionary of parameters to send with the request. | ||
Returns: | ||
Response: The response from the API. | ||
""" | ||
url = f"{self.base_url}/{endpoint}" | ||
response = self.session.get(url, params=params) | ||
response.raise_for_status() # Will raise an HTTPError if the HTTP request returned an unsuccessful status code | ||
return response | ||
|
||
def post(self, endpoint, data=None, json=None): | ||
""" | ||
Send a POST request to the API. | ||
Args: | ||
endpoint (str): The API endpoint to send the request to. | ||
data (dict, optional): A dictionary of data to send in the body of the request. | ||
json (dict, optional): A JSON serializable object to send in the body of the request. | ||
Returns: | ||
Response: The response from the API. | ||
""" | ||
url = f"{self.base_url}/{endpoint}" | ||
response = self.session.post(url, data=data, json=json) | ||
response.raise_for_status() | ||
return response | ||
|
||
|
||
def put(self, endpoint, data=None, json=None): | ||
""" | ||
Send a PUT request to the API. | ||
Args: | ||
endpoint (str): The API endpoint to send the request to. | ||
data (dict, optional): A dictionary of data to send in the body of the request. | ||
json (dict, optional): A JSON serializable object to send in the body of the request. | ||
Returns: | ||
Response: The response from the API. | ||
""" | ||
url = f"{self.base_url}/{endpoint}" | ||
response = self.session.put(url, data=data, json=json) | ||
response.raise_for_status() | ||
return response | ||
|
||
def delete(self, endpoint, params=None): | ||
""" | ||
Send a DELETE request to the API. | ||
Args: | ||
endpoint (str): The API endpoint to send the request to. | ||
params (dict, optional): A dictionary of parameters to send with the request. | ||
Returns: | ||
Response: The response from the API. | ||
""" | ||
url = f"{self.base_url}/{endpoint}" | ||
response = self.session.delete(url, params=params) | ||
response.raise_for_status() | ||
return response | ||
|
||
def patch(self, endpoint, data=None, json=None): | ||
""" | ||
Send a PATCH request to the API. | ||
Args: | ||
endpoint (str): The API endpoint to send the request to. | ||
data (dict, optional): A dictionary of data to send in the body of the request. | ||
json (dict, optional): A JSON serializable object to send in the body of the request. | ||
Returns: | ||
Response: The response from the API. | ||
""" | ||
url = f"{self.base_url}/{endpoint}" | ||
response = self.session.patch(url, data=data, json=json) | ||
response.raise_for_status() | ||
return response |
Oops, something went wrong.