Skip to main content

Detect encoding from CSV files and return the accepted case format for analytical tools (currently supports DuckDB)

Project description

codec_bridge

A Python utility library that bridges encoding mismatches between Python and DuckDB when reading raw CSV files.

🔍 Motivation

DuckDB recently introduced the encodings extension, supporting over a thousand character encodings. However, Python often detects encodings using a format or casing that DuckDB does not accept directly.

For example:

  • Python detects: ISO-8859-1
  • DuckDB expects: latin

This mismatch can break ingestion pipelines, especially when dealing with large volumes of raw CSV files from diverse sources. The goal of this library is to act as a bridge, translating Python-standard encoding names into DuckDB-compatible formats.

⚙️ Features

  • get_duckdb_encoding: Main method that maps Python encoding names to DuckDB-compatible formats.
  • 🔍 detect_encoding: Detects the encoding of a file using charset-normalizer.
  • 📌 detect_delimiter: Identifies the most likely delimiter used in a CSV file.
  • ✍️ write_utf8_csv: Rewrites a file to UTF-8 encoding when necessary.
  • 📦 process_files: Scans a directory of CSV files and returns metadata for each file.

📦 Installation

pip install codec_bridge

🔧 Requirements

This library depends on:

  • duckdb (>=1.3.2)
  • charset-normalizer (>=3.4.2)

These will be installed automatically when using pip install codec_bridge.

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

codec_bridge-0.2.4.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codec_bridge-0.2.4-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file codec_bridge-0.2.4.tar.gz.

File metadata

  • Download URL: codec_bridge-0.2.4.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for codec_bridge-0.2.4.tar.gz
Algorithm Hash digest
SHA256 9965f0d2dbf9463960358f7f8f3a7b873de36e7c2edf83975b645bafbab8a176
MD5 ceaa41c4b36bba5fb4e3314430c764f0
BLAKE2b-256 0a6134594830a8d6af45eb37aad5879f8767ce9e40aebeaa324241f3bf3db21c

See more details on using hashes here.

File details

Details for the file codec_bridge-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: codec_bridge-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for codec_bridge-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 84dc6e1f8751776a5b25b4e90c0d040a1d373f06e4cc2b8740ebb75a0d5a6de8
MD5 b8e2782c817b887e265d191184c79cab
BLAKE2b-256 12394d904a48725026949a6a734711a311d4da950f0100c7f6b167b9c76b0b0c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page