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