Skip to main content

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

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

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

  1. Bump the version in both places (they must match):

    • pyproject.toml → [project].version
    • src/__init__.py → __version__
  2. Install build tools (one-time):

    pip install build twine
    
  3. Run tests and commit the version bump.

  4. Build the package:

    python -m build
    

    This creates dist/bqcsv-<version>.tar.gz and dist/bqcsv-<version>-py3-none-any.whl.

  5. 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).

  6. 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.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bqcsv 1.1.0
File Size Uploaded
bqcsv-1.1.0.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bqcsv 1.1.0
File Interpreter ABI Platform
bqcsv-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.6 kB

Release files / bqcsv-1.1.0.tar.gz

Download URL bqcsv-1.1.0.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6b0ae6babf5e3d88e6ebf2dadfdb8c1ac1a3854066ad59ab4cf3f087c3b92bae
BLAKE2b-256 checksum
How to use checksums
dbaed1996f877ac9c43a9e1d91964cc0e4c53943c6648e65a1205a9d91167c4d
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.1.0-py3-none-any.whl

Download URL bqcsv-1.1.0-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
da4e46306016da852d7bee6ce40a41ee402b3b6c132669d40e79276c12667f2f
BLAKE2b-256 checksum
How to use checksums
f096b2ce26b16c287cc5b7927fe9e89a69e2c685cb1c03b40aeb0a6f2b89240e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0

Release history Release notifications | RSS feed

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

This release

1.1.0 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page