codec-bridge 0.2.5__tar.gz → 1.0.0__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.5/license.txt → codec_bridge-1.0.0/LICENSE +21 -21
- {codec_bridge-0.2.5 → codec_bridge-1.0.0}/PKG-INFO +89 -79
- {codec_bridge-0.2.5 → codec_bridge-1.0.0}/README.md +36 -36
- codec_bridge-1.0.0/codec_bridge/__init__.py +37 -0
- codec_bridge-1.0.0/codec_bridge/encoding_translator.py +380 -0
- codec_bridge-1.0.0/codec_bridge/py.typed +1 -0
- codec_bridge-1.0.0/codec_bridge/repository/python_to_duckdb.py +53 -0
- codec_bridge-1.0.0/codec_bridge/resolver.py +238 -0
- {codec_bridge-0.2.5 → codec_bridge-1.0.0}/codec_bridge.egg-info/PKG-INFO +89 -79
- {codec_bridge-0.2.5 → codec_bridge-1.0.0}/codec_bridge.egg-info/SOURCES.txt +5 -5
- codec_bridge-1.0.0/codec_bridge.egg-info/requires.txt +9 -0
- {codec_bridge-0.2.5 → codec_bridge-1.0.0}/codec_bridge.egg-info/top_level.txt +0 -1
- codec_bridge-1.0.0/pyproject.toml +65 -0
- {codec_bridge-0.2.5 → codec_bridge-1.0.0}/setup.cfg +4 -4
- codec_bridge-1.0.0/tests/test_integration.py +77 -0
- codec_bridge-1.0.0/tests/test_unit.py +211 -0
- codec_bridge-0.2.5/codec_bridge/encoding_translator.py +0 -125
- codec_bridge-0.2.5/codec_bridge/repository/__init__.py +0 -0
- codec_bridge-0.2.5/codec_bridge/repository/python_to_duckdb.py +0 -81
- codec_bridge-0.2.5/codec_bridge.egg-info/requires.txt +0 -2
- codec_bridge-0.2.5/pyproject.toml +0 -26
- codec_bridge-0.2.5/setup.py +0 -20
- codec_bridge-0.2.5/tests/__init__.py +0 -0
- codec_bridge-0.2.5/tests/duckdb_utils.py +0 -21
- codec_bridge-0.2.5/tests/generate_test_data.py +0 -60
- {codec_bridge-0.2.5/codec_bridge → codec_bridge-1.0.0/codec_bridge/repository}/__init__.py +0 -0
- {codec_bridge-0.2.5 → codec_bridge-1.0.0}/codec_bridge.egg-info/dependency_links.txt +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 João Pedro Ferraz Bezerra
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 João Pedro Ferraz Bezerra
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,79 +1,89 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: codec_bridge
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Detect encoding from CSV files and return the accepted case format for analytical tools (currently supports DuckDB)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
to
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Classifier:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
##
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codec_bridge
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Detect encoding from CSV files and return the accepted case format for analytical tools (currently supports DuckDB)
|
|
5
|
+
Author-email: João Pedro Ferraz Bezerra <jpferraz554@gmail.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2025 João Pedro Ferraz Bezerra
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/jpferraz-git/codec_bridge
|
|
29
|
+
Project-URL: Repository, https://github.com/jpferraz-git/codec_bridge
|
|
30
|
+
Project-URL: Issues, https://github.com/jpferraz-git/codec_bridge/issues
|
|
31
|
+
Project-URL: Changelog, https://github.com/jpferraz-git/codec_bridge/blob/main/CHANGELOG.md
|
|
32
|
+
Keywords: duckdb,encoding,csv,charset,transcode
|
|
33
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
34
|
+
Classifier: Programming Language :: Python :: 3
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
38
|
+
Classifier: Operating System :: OS Independent
|
|
39
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
40
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
41
|
+
Requires-Python: >=3.11
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
License-File: LICENSE
|
|
44
|
+
Requires-Dist: charset-normalizer>=3.4.2
|
|
45
|
+
Requires-Dist: duckdb>=1.3.2
|
|
46
|
+
Provides-Extra: dev
|
|
47
|
+
Requires-Dist: pytest; extra == "dev"
|
|
48
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
49
|
+
Requires-Dist: ruff; extra == "dev"
|
|
50
|
+
Requires-Dist: build; extra == "dev"
|
|
51
|
+
Requires-Dist: twine; extra == "dev"
|
|
52
|
+
Dynamic: license-file
|
|
53
|
+
|
|
54
|
+
# codec_bridge
|
|
55
|
+
|
|
56
|
+
A Python utility library that bridges encoding mismatches between Python and DuckDB when reading raw CSV files.
|
|
57
|
+
|
|
58
|
+
## Motivation
|
|
59
|
+
|
|
60
|
+
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.
|
|
61
|
+
|
|
62
|
+
For example:
|
|
63
|
+
- Python detects: `ISO-8859-1`
|
|
64
|
+
- DuckDB expects: `latin`
|
|
65
|
+
|
|
66
|
+
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.
|
|
67
|
+
|
|
68
|
+
## Features
|
|
69
|
+
|
|
70
|
+
- `get_duckdb_encoding`: Main method that maps Python encoding names to DuckDB-compatible formats.
|
|
71
|
+
- `detect_encoding`: Detects the encoding of a file using `charset-normalizer`.
|
|
72
|
+
- `detect_delimiter`: Identifies the most likely delimiter used in a CSV file.
|
|
73
|
+
- `write_utf8_csv`: Rewrites a file to UTF-8 encoding when necessary.
|
|
74
|
+
- `process_files`: Scans a directory of CSV files and returns metadata for each file.
|
|
75
|
+
|
|
76
|
+
## Installation
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install codec_bridge
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Requirements
|
|
83
|
+
|
|
84
|
+
This library depends on:
|
|
85
|
+
|
|
86
|
+
- `duckdb` (>=1.3.2)
|
|
87
|
+
- `charset-normalizer` (>=3.4.2)
|
|
88
|
+
|
|
89
|
+
These will be installed automatically when using `pip install codec_bridge`.
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
# codec_bridge
|
|
2
|
-
|
|
3
|
-
A Python utility library that bridges encoding mismatches between Python and DuckDB when reading raw CSV files.
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
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.
|
|
8
|
-
|
|
9
|
-
For example:
|
|
10
|
-
- Python detects: `ISO-8859-1`
|
|
11
|
-
- DuckDB expects: `latin`
|
|
12
|
-
|
|
13
|
-
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.
|
|
14
|
-
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
##
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
pip install codec_bridge
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
##
|
|
30
|
-
|
|
31
|
-
This library depends on:
|
|
32
|
-
|
|
33
|
-
- `duckdb` (>=1.3.2)
|
|
34
|
-
- `charset-normalizer` (>=3.4.2)
|
|
35
|
-
|
|
36
|
-
These will be installed automatically when using `pip install codec_bridge`.
|
|
1
|
+
# codec_bridge
|
|
2
|
+
|
|
3
|
+
A Python utility library that bridges encoding mismatches between Python and DuckDB when reading raw CSV files.
|
|
4
|
+
|
|
5
|
+
## Motivation
|
|
6
|
+
|
|
7
|
+
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.
|
|
8
|
+
|
|
9
|
+
For example:
|
|
10
|
+
- Python detects: `ISO-8859-1`
|
|
11
|
+
- DuckDB expects: `latin`
|
|
12
|
+
|
|
13
|
+
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.
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- `get_duckdb_encoding`: Main method that maps Python encoding names to DuckDB-compatible formats.
|
|
18
|
+
- `detect_encoding`: Detects the encoding of a file using `charset-normalizer`.
|
|
19
|
+
- `detect_delimiter`: Identifies the most likely delimiter used in a CSV file.
|
|
20
|
+
- `write_utf8_csv`: Rewrites a file to UTF-8 encoding when necessary.
|
|
21
|
+
- `process_files`: Scans a directory of CSV files and returns metadata for each file.
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install codec_bridge
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Requirements
|
|
30
|
+
|
|
31
|
+
This library depends on:
|
|
32
|
+
|
|
33
|
+
- `duckdb` (>=1.3.2)
|
|
34
|
+
- `charset-normalizer` (>=3.4.2)
|
|
35
|
+
|
|
36
|
+
These will be installed automatically when using `pip install codec_bridge`.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
2
|
+
|
|
3
|
+
from codec_bridge.encoding_translator import (
|
|
4
|
+
EncodingDetectionError,
|
|
5
|
+
detect_delimiter,
|
|
6
|
+
detect_encoding,
|
|
7
|
+
get_duckdb_encoding,
|
|
8
|
+
process_files,
|
|
9
|
+
read_csv_auto_encoding,
|
|
10
|
+
write_utf8_csv,
|
|
11
|
+
)
|
|
12
|
+
from codec_bridge.resolver import (
|
|
13
|
+
EncodingResolution,
|
|
14
|
+
UnsupportedEncodingError,
|
|
15
|
+
normalize_name,
|
|
16
|
+
resolve_encoding,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
try:
|
|
20
|
+
__version__ = version("codec_bridge")
|
|
21
|
+
except PackageNotFoundError:
|
|
22
|
+
__version__ = "1.0.0"
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"EncodingDetectionError",
|
|
26
|
+
"EncodingResolution",
|
|
27
|
+
"UnsupportedEncodingError",
|
|
28
|
+
"__version__",
|
|
29
|
+
"detect_delimiter",
|
|
30
|
+
"detect_encoding",
|
|
31
|
+
"get_duckdb_encoding",
|
|
32
|
+
"normalize_name",
|
|
33
|
+
"process_files",
|
|
34
|
+
"read_csv_auto_encoding",
|
|
35
|
+
"resolve_encoding",
|
|
36
|
+
"write_utf8_csv",
|
|
37
|
+
]
|