Convert your csvs fast
Project description
CSVS Convert
Converts CSV files into XLSX/SQLITE/POSTGRESQL/PARQUET fast.
Install
pip install csvs_convert
Docs
Aims
- Thorough type guessing of CSV columns, so there is no need to configure types of each field. Scans whole file first to make sure all types in a column are consistent. Can detect over 30 date/time formats as well as JSON data.
- Quick conversions/type guessing (uses rust underneath). Uses fast methods specific for each output format:
copy
for postgres- Prepared statements for sqlite using c API.
- Arrow reader for parquet
- Write only mode for libxlsxwriter
- Tries to limit errors when inserting data into database by resorting to "text" if type guessing can't determine a more specific type.
- When inserting into existing databases automatically migrate schema of target to allow for new data (
evolve
option). - Memory efficient. All csvs and outputs are streamed so all conversions should take up very little memory.
- Gather stats and information about CSV files into datapacakge.json file which can use it for customizing conversion.
Drawbacks
- CSV files currently need header rows.
- Whole file needs to be on disk as whole CSV is analyzed therefore files are read twice.
Conversion Docs
This is the python library, providing bindings to the rust library.
Usage From CSV files.
import csvs_convert
#sqlite
csvs_convert.csvs_to_sqlite("sqlite.db", ["file.csv"])
#postgres
csvs_convert.csvs_to_postgres("postgresql://user:postgres@localhost/db", ["file.csv"])
#parquet
csvs_convert.csvs_to_parquet("output", ["file.csv"])
#xlsx
csvs_convert.csvs_to_xlsx("output.xlsx", ["sqlite.db"])
Usage from datapackage
A datapackage is a file that contains metadata about the tables its specification is described here.
To generate datapackage.json
file you can use:
csvs_convert.csvs_to_datapackage('path/to/datapackage.json', ["fixtures/large/csv/data.csv"])
Other tools can also generate these files.
You can use this file and alter it as needed. Mostly it is useful if you want to use the same schema across multiple files, as it will save time not having to do the type guessing for every file.
When referring to a datapackage you can either reference:
- A
datapackage.json
file. - A datapackage directory containing a
datapackage.json
file. e.g./a/datapackage/dir
- A zip file containing a
datapackage.json
file. e.g.my_datapackage.zip
Examples:
import csvs_convert
#sqlite
csvs_convert.datapackage_to_sqlite("sqlite.db", "path/to/datapackage.json")
#postgres
csvs_convert.datapackage_to_postgres("postgresql://user:postgres@localhost/db", "path/to/datapackage.json")
#parquet
csvs_convert.datapackage_to_parquet("path/to/directory", ["sqlite.db"])
#xlsx
csvs_convert.datapackage_to_xlsx("output.xlsx", "path/to/datapackage.json")
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
csvs_convert-0.7.2.tar.gz
(99.0 kB
view hashes)
Built Distributions
Close
Hashes for csvs_convert-0.7.2-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d66a6bc73f34f7af700982fa310b6d83e84ea2333b17a4944f2460479ccde02 |
|
MD5 | 13b7a07404abff4c3529cfdd8402504f |
|
BLAKE2b-256 | c269e3307484be4d53adf31c2443c19161568ec9912acc2befcbf2067d2126f8 |
Close
Hashes for csvs_convert-0.7.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be80797a66f9acf3e1501b5c845834f331d69e32c98373e943e831eb8fe79003 |
|
MD5 | f2c32b726bd5b68b934302eb01852008 |
|
BLAKE2b-256 | cf7598e3b3f46880152ffbc7549dfd1a19934d726d5a3488e9c8f5d87c12f22b |
Close
Hashes for csvs_convert-0.7.2-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99bca628047042d6ec8f447cc191ac45c32fbfc4de977edef826a771efb3b894 |
|
MD5 | 503579193f82feb9ad0a2e2a1af241fa |
|
BLAKE2b-256 | 407b8b50fae0643475161402b39242b3991310f63a7752f210d0560730ade32a |
Close
Hashes for csvs_convert-0.7.2-cp311-cp311-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e555f2b743cc0fd4c4d37e3f988490cb609ed976f05848cfd09a95b9aa4b9be0 |
|
MD5 | a0773aa62c089c04dc2b4922b3e80f24 |
|
BLAKE2b-256 | 7ebcde103eea422fbfeff5113e634058eb83af3abe41510632f70d35e6271596 |
Close
Hashes for csvs_convert-0.7.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86f385e3347c1734eb204a59016bfd50e637424d566022587a57a3f9c982b52a |
|
MD5 | ba2fdc591457b52db5130ece1b698fe9 |
|
BLAKE2b-256 | c62570c85e2b1d5ec48e14352f37ee48cf9e8618bde28ec5870e3c42952bada0 |
Close
Hashes for csvs_convert-0.7.2-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bc286b55d94217221da01b86846d306b83382a1fb7cc7fc365bbc0bbfb5e45d |
|
MD5 | 74246437ecd4e82719dc481fc8d70469 |
|
BLAKE2b-256 | 6010e463105048edd0fa2ad5c5b6088bf14d9ab6c101b5e40d11cbb1b19e4d13 |
Close
Hashes for csvs_convert-0.7.2-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6519196119d1e83bffb4e417c535999aad0d2fe73d0b5524e8fd4a1d84b31a03 |
|
MD5 | 3321ad42859adbb591ed9a03a4066990 |
|
BLAKE2b-256 | d33424a006c7ef0c953bc28e627b90f925ecd4d5b4ad55ac01e1d97074cfc09e |
Close
Hashes for csvs_convert-0.7.2-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c8e3d799b4644facf727f266581c59eab49a6b305b6f47da55abb8bcb913c53 |
|
MD5 | 422cfbe7de41bd1f10cbd1982736e7fc |
|
BLAKE2b-256 | 94c5fc7aa83068c61d781ed0ad3f6efe7081fc7d55b7eec5931e3ddf0d178c4b |
Close
Hashes for csvs_convert-0.7.2-cp39-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4fa367572d95aec4c66a8a127cf5e8cdd17246f2b289afb2c300366839e9232 |
|
MD5 | a88d1694a61cf2c94cc013a3b850e957 |
|
BLAKE2b-256 | 4fba35b7d533f4cf36f02aea12907e8360d18df3a1913b1fb5dc4d225e4d9eea |
Close
Hashes for csvs_convert-0.7.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bba2b0c342a79cb8cc57ff7f2c3738f1c6859d8efdd821e53ea5e29fe13cbac9 |
|
MD5 | e429c366a3b38e763d638e9b03d741bc |
|
BLAKE2b-256 | b8377c029b06dce4d4f8178b5f80a016d5a42b5a9a5814d10a0556b0de206ef6 |
Close
Hashes for csvs_convert-0.7.2-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 841264ca85f2f2d0a168432a3fa1e2606eccdc3d1b0ca2589b286977e81ad593 |
|
MD5 | 16bda3cd597db0ab847cec2e3329721f |
|
BLAKE2b-256 | 73a397085875cc0e4f68cf5f78d18303d336d39648076ad97dae9fdbd1b58003 |
Close
Hashes for csvs_convert-0.7.2-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c31e837849d17249aecac4f04adc6fdf2d12a5603cb28e94094fc205bff07ffd |
|
MD5 | f0100d7d26b52396a2a566f599df6ea4 |
|
BLAKE2b-256 | 9011daf13938b460df17947a01331d1b4432f22a99d6d298fc2adea2aaf31dc8 |
Close
Hashes for csvs_convert-0.7.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f319a593fad2123bfc6584aa863c7b627b0fc61f531e893275e13944946268d |
|
MD5 | 4abff5000afd28399a1e11dd07975ebe |
|
BLAKE2b-256 | 52b09ec695b5583fa339a444b79a96b9b29221e341a96c65a064b3b2618df45d |
Close
Hashes for csvs_convert-0.7.2-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e33fcde158a068cd90a661506661a7f32bcd60527d75d51d86fbf9225220a68 |
|
MD5 | 0b75726832f853668e6215dd6f351633 |
|
BLAKE2b-256 | dada5554f9d9d3d32c189e051d2b1dfaabc037ff921dc0595a6fe27110bc8a2b |
Close
Hashes for csvs_convert-0.7.2-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c45a50c3f0208de09cc14f08134067c8cd94062a8bf5a32df57feb3b5675ff19 |
|
MD5 | 5800033c450bc4041d4f9f2001853202 |
|
BLAKE2b-256 | af4850f0f31062d922ef4166e053b871d86145eb5074b9b71c9f7faa73eac1b0 |
Close
Hashes for csvs_convert-0.7.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09d172eacd95f58615de75e82fe79bd022db5671703b962e8ac86db4f64571e5 |
|
MD5 | b4cd1f307d49545de2e45c2f90d96861 |
|
BLAKE2b-256 | 3700ef7ccd53f0e8c7d02c8089699469e4d91fc1c05f68f1f30a86a71e325966 |
Close
Hashes for csvs_convert-0.7.2-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0bf9b1e0a3e1bc97c054636e7c7f3a2a380d8b318b223326f249cb0278f2780 |
|
MD5 | dfead3df03e8857a16a78ad01dea030d |
|
BLAKE2b-256 | e3a5ad2565a6584a445aa1909f957e86641ec271d578bd2e10b511c1640d3112 |
Close
Hashes for csvs_convert-0.7.2-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27fdfaace36a95d6b32af063d3bf6079a05fb98bc32bfccd2fbf28a96aac1c77 |
|
MD5 | eb7822063f37d04335258dc8d9c251ab |
|
BLAKE2b-256 | 28a62bba306c7cc3413b1ea41fb71c4bccd230daa820ff2a0cfaadb7e684ee3f |