Detect types of columns in delimited files using DuckDB and pandas
Project description
Column Type Detector
A simple Python utility to detect the data types of columns in a delimited file using DuckDB and Pandas.
Overview
This tool loads a delimited file into an in-memory DuckDB database treating all columns as VARCHAR.
It analyzes each column to detect data types: int, float, double, str, or null, and outputs a summary table.
Requirements
- Python >=3.12.3+
- duckdb >=1.3.2
- pandas >=2.1.4
Installation
pip install duckdb>=1.3.2 pandas>=2.1.4
Example CLI Wrapper
from columnTypeDetector import load_data_as_varchar, get_column_names, detect_column_types
con = load_data_as_varchar('/content/sample_data/All_Customers.csv',',')
get_column_names(con,"raw_data")
detect_column_types(con,"raw_data")
Sample Output
Here is an example output of the type detection:
| col | float | int | null | str | double | total |
|---|---|---|---|---|---|---|
| Address1 | 0 | 3 | 0 | 2496 | 0 | 2499 |
| Address2 | 0 | 0 | 2499 | 0 | 0 | 2499 |
| Address3 | 0 | 0 | 2499 | 0 | 0 | 2499 |
| City | 0 | 0 | 7 | 2492 | 0 | 2499 |
| City2 | 0 | 0 | 2495 | 4 | 0 | 2499 |
| Company | 1 | 0 | 0 | 2498 | 0 | 2499 |
| Country | 0 | 0 | 58 | 2441 | 0 | 2499 |
| CreateDate | 0 | 0 | 0 | 2499 | 0 | 2499 |
| Currency | 0 | 81 | 0 | 2418 | 0 | 2499 |
| CustomerID | 0 | 2495 | 0 | 4 | 0 | 2499 |
| CustomerTier | 0 | 457 | 171 | 1871 | 0 | 2499 |
| Firstname | 0 | 0 | 0 | 2499 | 0 | 2499 |
| Lastname | 0 | 0 | 0 | 2499 | 0 | 2499 |
| MiscDate | 0 | 0 | 0 | 2499 | 0 | 2499 |
| OrderAmount | 0 | 2498 | 0 | 1 | 0 | 2499 |
| PrefDelivMethod | 0 | 0 | 0 | 2499 | 0 | 2499 |
| State | 0 | 107 | 0 | 2392 | 0 | 2499 |
| Status | 0 | 0 | 0 | 2499 | 0 | 2499 |
| Zip | 0 | 2410 | 0 | 89 | 0 | 2499 |
License
MIT License
Project details
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 columntypedetector-0.1.6.tar.gz.
File metadata
- Download URL: columntypedetector-0.1.6.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2df3e9bee699c69ffe79a65bdec71a2596a4ad139f88aa69f0e7c2b3b5a9cbd3
|
|
| MD5 |
d47e9a8a9c449a625292f8b0f46c2ba3
|
|
| BLAKE2b-256 |
92a4ff28f748b34e7a615912bbccee3a9a997fcd9a4620cfdbf147f44fa71911
|
File details
Details for the file columntypedetector-0.1.6-py3-none-any.whl.
File metadata
- Download URL: columntypedetector-0.1.6-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f957a36e58f6346fd76e60027635e828ed7cfde78ab6d354bf9c613cbba0c22
|
|
| MD5 |
f0948a797cd6868cb6d2b62d998305e9
|
|
| BLAKE2b-256 |
cbc8f336bd770a2db859601b8c69fe6793211bc1139a9fce90c0d9bd3e607031
|