bqcsv
Upload a local CSV file to BigQuery using the bq CLI and your existing gcloud authentication.
Why a dedicated CLI tool?
Out of the box, Google's bq CLI cannot create a table with column names inferred from a CSV file.
bqcsv fixes that:
- detects the schema from the CSV file
- creates a table with proper column names and types
- loads the CSV file using
bq load
Authentication
No additional authentication is needed.
bqcsv uses your existing authentication via gcloud auth login.
Requirements
- Python 3.10+
- Google Cloud SDK with
bqon yourPATH
How to use bqcsv
Upload a CSV file to a table
To upload a CSV file, specify your project ID, dataset ID, and table name:
bqcsv data.csv --project my-gcp-project --dataset staging --table events_raw
The --table argument is optional. By default, bqcsv derives the table name from the CSV file:
bqcsv data.csv --project my-gcp-project --dataset staging
# is identical to
bqcsv data.csv --project my-gcp-project --dataset staging --table data
Saving your configuration
To avoid passing --project, --dataset, or --table on every run, save them to your local config:
bqcsv config set --project my-gcp-project --dataset analytics --table events
bqcsv config show
Defaults are stored in ~/.config/bqcsv/config.toml.
After you set your defaults, you can call bqcsv without arguments:
bqcsv data.csv
If you have not set a default --table value, the table name is derived from the CSV file.
Development
Install from your local repo
pip install -e .
Testing
After installing the package locally (pip install -e .), run the unit tests with:
python -m unittest discover -s tests -v
This discovers and runs all tests under tests/ without needing BigQuery credentials.
To run a single test or test class, pass its dotted path to unittest:
# one test method
python -m unittest tests.test_uploader.InferSchemaTests.test_comma_csv_infers_typed_columns -v
# all tests in a class
python -m unittest tests.test_cli.ResolveTableNameTests -v
To run all tests in one file, use the module path (drop .py from the filename under tests/):
python -m unittest tests.test_uploader -v
python -m unittest tests.test_cli -v
To delete a test table, use bq:
bq rm -f -t PROJECT_ID:DATASET_ID.TABLE_NAME
You can run the module directly when working on a new feature or fixing a bug:
python -m src.cli config set --project PROJECT_ID --dataset DATASET_ID --table TEST_TABLE_NAME
Releasing to PyPI
-
Bump the version in both places (they must match):
pyproject.toml→[project].versionsrc/__init__.py→__version__
-
Install build tools (one-time):
pip install build twine
-
Run tests and commit the version bump.
-
Build the package:
python -m build
This creates
dist/bqcsv-<version>.tar.gzanddist/bqcsv-<version>-py3-none-any.whl. -
Upload to PyPI:
twine upload dist/*
On first upload, create an account at pypi.org and use an API token as the password (
__token__as the username). -
Tag the release (optional but recommended):
git tag v0.2.0 git push origin v0.2.0
After publishing, users can install the new version with:
pip install --upgrade bqcsv
Metadata
Release files for bqcsv 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bqcsv-1.3.1.tar.gz | 12.2 kB | Without provenance | Details for bqcsv-1.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bqcsv-1.3.1-py3-none-any.whl | Python 3 | none | any | Details for bqcsv-1.3.1-py3-none-any.whl |
Total release size: 23.9 kB
Release files / bqcsv-1.3.1.tar.gz
| Download URL | bqcsv-1.3.1.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
399c738691ed193c3bb556cfeb73393cadb29db95202631603db05f8967307bb
|
|
BLAKE2b-256 checksum How to use checksums |
cc606dd02307e1821512035a18755ab30f3dc9ffa98fd53bd1950007e9f6d5b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.0
|
Release files / bqcsv-1.3.1-py3-none-any.whl
| Download URL | bqcsv-1.3.1-py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
98e66cc877a44e946c7601b839498124c8ec06424d807cc468c8da8d37fc78bb
|
|
BLAKE2b-256 checksum How to use checksums |
2aa751675d95ac21d97d547d3427376db435c3a82b1bce8f60503d7c36b29b3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.0
|
Security for bqcsv 1.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.