A helpful module for downloading, processing and ingesting data
Project description
CTG-Data-Helpers
This directory contains modules we developed to help with data processing, downloading and ingesting.
Required dependencies:
loggingospathlibhashlibpkgutiliozipfiletempfilepandasrequestssqlalchemypsycopg2-binary
Download Functions
The first set of functions in the module assist with downloading data
get_path() - A string representing the path to the file or directory. If a path is provided, will return that path. If a path is not provided, will provide a new path based on a temp directory and the hash of the URL.
make_path() - If a path doesn't exist, get_path() internally calls this function to build a new path. (Essentially a wrapper function around os.mkdir to catch errors)
hash_url() - Hashes the given download URL to help build the temp path if none has been given.
pure_download() - Downloads the data from the URL with the capacity to handle zip files if specified.
download_data_cache() - Checks before calling pure_download() to see if the data has previously been downloaded. If the data is already in the cache, the function just returns the path to that data, without downloading it a second time.
Pandas Functions
The second set of functions in the module assist with setting up the data in Pandas DataFrames for easier processing
setup_df() - Given a set of specified parameters, this function ingests the CSV to a DataFrame. Note: **cli_options is integrated with our click-based command-line-interfaces.
PostgreSQL Functions
These functions help with setting up the database, confirming a successful upload, and uploading the data itself
get_engine() - Given the set environmental variables, returns an engine to connect to the database.
confirm_table() - After data has been ingested, confirms that the data was successfully uploaded to the database.
upload_data() - Uploads the data of a specific DataFrame to the database given some predetermined variables
has_primary_key() - Checks to see if an existing table has a primary key
set_primary_keys() - Given a table name and a list of columns for a primary key, this function creates the primary key.
Extension Functions
build_plugins_map() - This function helps dynamically build a plugin map when using this code in a command-line environment
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ctg-data-helpers-0.0.1.tar.gz.
File metadata
- Download URL: ctg-data-helpers-0.0.1.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5aa79d65f723cc6891b93b7813bb683d80f9292341835f2beb9b2e950d09394
|
|
| MD5 |
d3f2d8104a0fbb1cb52e8f6c89825eb2
|
|
| BLAKE2b-256 |
8cc83516658d8433f7a360a8de1e943b28c205d985e80c34f4d8b34f813a4f47
|
File details
Details for the file ctg_data_helpers-0.0.1-py3-none-any.whl.
File metadata
- Download URL: ctg_data_helpers-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
363418f8dfacf2059a58ef104500d01e55f685f6c1cbb31408bfd66575cca669
|
|
| MD5 |
dbf5695068c15523c7e2e0067da0be8c
|
|
| BLAKE2b-256 |
8fffebadd2e347f7398fce465d31f9f3a3be6213a67995860d17ee760f6e4127
|