codec-bridge 0.2.3__tar.gz → 0.2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/PKG-INFO +1 -1
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/codec_bridge/encoding_translator.py +16 -5
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/codec_bridge/repository/python_to_duckdb.py +1 -0
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/codec_bridge.egg-info/PKG-INFO +1 -1
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/pyproject.toml +1 -1
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/setup.py +1 -1
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/README.md +0 -0
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/codec_bridge/__init__.py +0 -0
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/codec_bridge/repository/__init__.py +0 -0
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/codec_bridge.egg-info/SOURCES.txt +0 -0
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/codec_bridge.egg-info/dependency_links.txt +0 -0
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/codec_bridge.egg-info/requires.txt +0 -0
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/codec_bridge.egg-info/top_level.txt +0 -0
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/license.txt +0 -0
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/setup.cfg +0 -0
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/tests/__init__.py +0 -0
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/tests/duckdb_utils.py +0 -0
- {codec_bridge-0.2.3 → codec_bridge-0.2.5}/tests/generate_test_data.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codec_bridge
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Detect encoding from CSV files and return the accepted case format for analytical tools (currently supports DuckDB)
|
|
5
5
|
Home-page: https://github.com/jpferraz-git/codec_bridge
|
|
6
6
|
Author: João Pedro Ferraz Bezerra
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import charset_normalizer
|
|
2
2
|
import os
|
|
3
3
|
import re
|
|
4
|
+
import logging
|
|
4
5
|
|
|
5
6
|
from codec_bridge.repository.python_to_duckdb import PYTHON_TO_DUCKDB_ENCODING, ENCODINGS_UNDERSCORE_CONFLICT
|
|
6
7
|
|
|
8
|
+
logger = logging.getLogger(__name__)
|
|
7
9
|
def get_duckdb_encoding(python_encoding_name: str) -> str:
|
|
8
10
|
"""
|
|
9
11
|
Translates a Python-standard encoding name to the name expected by DuckDB.
|
|
@@ -13,10 +15,19 @@ def get_duckdb_encoding(python_encoding_name: str) -> str:
|
|
|
13
15
|
:return: The translated encoding name for DuckDB (e.g., 'ibm-819').
|
|
14
16
|
"""
|
|
15
17
|
if not python_encoding_name:
|
|
16
|
-
return
|
|
18
|
+
return "utf-8"
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
normalized = python_encoding_name.lower()
|
|
21
|
+
|
|
22
|
+
duckdb_encoding = PYTHON_TO_DUCKDB_ENCODING.get(normalized)
|
|
23
|
+
|
|
24
|
+
if duckdb_encoding is None:
|
|
25
|
+
logger.warning(
|
|
26
|
+
f"Encoding {python_encoding_name} not mapped yet, falling back to utf-8"
|
|
27
|
+
)
|
|
28
|
+
return "utf-8"
|
|
29
|
+
|
|
30
|
+
return duckdb_encoding
|
|
20
31
|
|
|
21
32
|
|
|
22
33
|
def detect_encoding(file_path: str, chunk: int = 1000000) -> str:
|
|
@@ -51,7 +62,7 @@ def detect_delimiter(file_path: str, encoding: str = "utf-8") -> str:
|
|
|
51
62
|
if any(c > 0 for c in counts.values()):
|
|
52
63
|
detected_delimiter = max(counts, key=counts.get)
|
|
53
64
|
except Exception as e:
|
|
54
|
-
|
|
65
|
+
logger.warning(f" Could not detect delimiter for {os.path.basename(file_path)}: {e}")
|
|
55
66
|
|
|
56
67
|
return detected_delimiter
|
|
57
68
|
|
|
@@ -65,7 +76,7 @@ def process_files(directory_path: str) -> list[dict]:
|
|
|
65
76
|
:return: A list of dictionaries, each containing metadata for a file.
|
|
66
77
|
"""
|
|
67
78
|
if not os.path.isdir(directory_path):
|
|
68
|
-
|
|
79
|
+
logger.warning(f"Error: The directory '{directory_path}' does not exist.")
|
|
69
80
|
return []
|
|
70
81
|
|
|
71
82
|
results = []
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codec_bridge
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Detect encoding from CSV files and return the accepted case format for analytical tools (currently supports DuckDB)
|
|
5
5
|
Home-page: https://github.com/jpferraz-git/codec_bridge
|
|
6
6
|
Author: João Pedro Ferraz Bezerra
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "codec_bridge"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.5"
|
|
4
4
|
description = "Detect encoding from CSV files and return the accepted case format for analytical tools (currently supports DuckDB)"
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "João Pedro Ferraz Bezerra", email = "jpferraz554@gmail.com" }
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name='codec_bridge',
|
|
5
|
-
version='0.2.
|
|
5
|
+
version='0.2.5',
|
|
6
6
|
packages=find_packages(),
|
|
7
7
|
description='Encoding and case normalization bridge for DuckDB and other engines',
|
|
8
8
|
long_description=open('README.md', encoding='utf-8').read(),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|