codec-bridge 0.2.0__tar.gz → 0.2.1__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.0 → codec_bridge-0.2.1}/PKG-INFO +2 -2
- {codec_bridge-0.2.0 → codec_bridge-0.2.1}/pyproject.toml +2 -2
- {codec_bridge-0.2.0 → codec_bridge-0.2.1}/setup.py +3 -3
- {codec_bridge-0.2.0 → codec_bridge-0.2.1}/src/codec_bridge/encoding_translator.py +2 -28
- {codec_bridge-0.2.0 → codec_bridge-0.2.1}/src/codec_bridge.egg-info/PKG-INFO +2 -2
- {codec_bridge-0.2.0 → codec_bridge-0.2.1}/src/codec_bridge.egg-info/SOURCES.txt +3 -1
- {codec_bridge-0.2.0 → codec_bridge-0.2.1}/src/codec_bridge.egg-info/top_level.txt +1 -0
- codec_bridge-0.2.1/src/repository/__init__.py +0 -0
- codec_bridge-0.2.1/src/repository/python_to_duckdb.py +80 -0
- {codec_bridge-0.2.0 → codec_bridge-0.2.1}/README.md +0 -0
- {codec_bridge-0.2.0 → codec_bridge-0.2.1}/license.txt +0 -0
- {codec_bridge-0.2.0 → codec_bridge-0.2.1}/setup.cfg +0 -0
- {codec_bridge-0.2.0 → codec_bridge-0.2.1}/src/codec_bridge/__init__.py +0 -0
- {codec_bridge-0.2.0 → codec_bridge-0.2.1}/src/codec_bridge.egg-info/dependency_links.txt +0 -0
- {codec_bridge-0.2.0 → codec_bridge-0.2.1}/src/codec_bridge.egg-info/requires.txt +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.1
|
|
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
|
|
@@ -31,7 +31,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
31
31
|
Classifier: Operating System :: OS Independent
|
|
32
32
|
Classifier: Operating System :: Microsoft :: Windows
|
|
33
33
|
Classifier: Operating System :: POSIX :: Linux
|
|
34
|
-
Requires-Python: >=3.
|
|
34
|
+
Requires-Python: >=3.11
|
|
35
35
|
Description-Content-Type: text/markdown
|
|
36
36
|
License-File: license.txt
|
|
37
37
|
Requires-Dist: charset-normalizer>=3.4.2
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "codec_bridge"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.1"
|
|
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" }
|
|
7
7
|
]
|
|
8
8
|
license = { file = "license.txt"}
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
11
|
|
|
12
12
|
dependencies = [
|
|
13
13
|
"charset-normalizer>=3.4.2",
|
|
@@ -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.1',
|
|
6
6
|
packages=find_packages(where="src"),
|
|
7
7
|
package_dir={"": "src"},
|
|
8
8
|
description='Encoding and case normalization bridge for DuckDB and other engines',
|
|
@@ -12,10 +12,10 @@ setup(
|
|
|
12
12
|
author_email='jpferraz554@gmail.com',
|
|
13
13
|
url='https://github.com/jpferraz-git/codec_bridge',
|
|
14
14
|
classifiers=[
|
|
15
|
-
'Programming Language :: Python :: 3.
|
|
15
|
+
'Programming Language :: Python :: 3.11',
|
|
16
16
|
'Operating System :: OS Independent',
|
|
17
17
|
'Operating System :: Microsoft :: Windows',
|
|
18
18
|
'Operating System :: POSIX :: Linux',
|
|
19
19
|
],
|
|
20
|
-
python_requires='>=3.
|
|
20
|
+
python_requires='>=3.11',
|
|
21
21
|
)
|
|
@@ -2,7 +2,7 @@ import charset_normalizer
|
|
|
2
2
|
import os
|
|
3
3
|
import re
|
|
4
4
|
|
|
5
|
-
from repository.python_to_duckdb import PYTHON_TO_DUCKDB_ENCODING, ENCODINGS_UNDERSCORE_CONFLICT
|
|
5
|
+
from src.repository.python_to_duckdb import PYTHON_TO_DUCKDB_ENCODING, ENCODINGS_UNDERSCORE_CONFLICT
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
def get_duckdb_encoding(python_encoding_name: str) -> str:
|
|
@@ -112,30 +112,4 @@ def write_utf8_csv(file_path: str, new_csv_file_path: str):
|
|
|
112
112
|
with open(file_path, 'r') as file:
|
|
113
113
|
with open(new_csv_file_path, 'w', encoding='utf-8') as new_file:
|
|
114
114
|
for line in file:
|
|
115
|
-
new_file.write(line)
|
|
116
|
-
|
|
117
|
-
if __name__ == "__main__":
|
|
118
|
-
import duckdb
|
|
119
|
-
from tests.duckdb_utils import create_table_from_csv
|
|
120
|
-
|
|
121
|
-
csv_directory_path = "//tests/assets/"
|
|
122
|
-
|
|
123
|
-
connection = duckdb.connect(database=":memory:")
|
|
124
|
-
|
|
125
|
-
connection.execute("INSTALL encodings")
|
|
126
|
-
connection.execute("LOAD encodings")
|
|
127
|
-
|
|
128
|
-
detector = get_duckdb_encoding(csv_directory_path)
|
|
129
|
-
|
|
130
|
-
file_results = process_files(csv_directory_path)
|
|
131
|
-
|
|
132
|
-
for result in file_results:
|
|
133
|
-
create_table_from_csv(
|
|
134
|
-
conn=connection,
|
|
135
|
-
file_path=result["path"],
|
|
136
|
-
table_name=result["table_name"],
|
|
137
|
-
delimiter=result["delimiter"],
|
|
138
|
-
encoding=result["duckdb_encoding"]
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
connection.close()
|
|
115
|
+
new_file.write(line)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codec_bridge
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
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
|
|
@@ -31,7 +31,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
31
31
|
Classifier: Operating System :: OS Independent
|
|
32
32
|
Classifier: Operating System :: Microsoft :: Windows
|
|
33
33
|
Classifier: Operating System :: POSIX :: Linux
|
|
34
|
-
Requires-Python: >=3.
|
|
34
|
+
Requires-Python: >=3.11
|
|
35
35
|
Description-Content-Type: text/markdown
|
|
36
36
|
License-File: license.txt
|
|
37
37
|
Requires-Dist: charset-normalizer>=3.4.2
|
|
@@ -8,4 +8,6 @@ src/codec_bridge.egg-info/PKG-INFO
|
|
|
8
8
|
src/codec_bridge.egg-info/SOURCES.txt
|
|
9
9
|
src/codec_bridge.egg-info/dependency_links.txt
|
|
10
10
|
src/codec_bridge.egg-info/requires.txt
|
|
11
|
-
src/codec_bridge.egg-info/top_level.txt
|
|
11
|
+
src/codec_bridge.egg-info/top_level.txt
|
|
12
|
+
src/repository/__init__.py
|
|
13
|
+
src/repository/python_to_duckdb.py
|
|
File without changes
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
PYTHON_TO_DUCKDB_ENCODING = {
|
|
2
|
+
# --- UTF-8 ---
|
|
3
|
+
'utf_8': 'utf-8',
|
|
4
|
+
'utf8': 'utf_8',
|
|
5
|
+
'utf_16': 'utf-16',
|
|
6
|
+
'utf-16': 'utf-16',
|
|
7
|
+
'utf_16be': 'utf-16-be',
|
|
8
|
+
'utf_16le': 'utf-16-le',
|
|
9
|
+
|
|
10
|
+
# --- ASCII ---
|
|
11
|
+
'ascii': 'ascii',
|
|
12
|
+
'us-ascii': 'ascii',
|
|
13
|
+
'ibm-367_p100-1995': 'ascii',
|
|
14
|
+
'iso-ir-6': 'ascii',
|
|
15
|
+
|
|
16
|
+
# --- Latin-1 (Ocidental Europe) ---
|
|
17
|
+
'latin-1': 'latin_1',
|
|
18
|
+
'latin1': 'latin_1',
|
|
19
|
+
'iso-8859-1': 'latin_1',
|
|
20
|
+
'iso_8859_1': 'latin_1',
|
|
21
|
+
'ibm-819': 'latin_1',
|
|
22
|
+
'cp819': 'latin_1',
|
|
23
|
+
'iso8859_1': 'latin_1',
|
|
24
|
+
'iso8859_14': 'ISO_8859_14',
|
|
25
|
+
'iso8859_10': 'ISO_8859_10',
|
|
26
|
+
|
|
27
|
+
# --- Windows-1252 ---
|
|
28
|
+
'windows-1252': 'ISO8859_1',
|
|
29
|
+
'cp1252': 'windows_1252',
|
|
30
|
+
|
|
31
|
+
# --- Latin-2 (Central Europe / Oriental Europe) ---
|
|
32
|
+
'iso-8859-2': 'latin_2',
|
|
33
|
+
'iso_8859_2': 'latin_2',
|
|
34
|
+
'latin-2': 'latin_2',
|
|
35
|
+
'latin2': 'latin_2',
|
|
36
|
+
'windows-1250': 'CP1250',
|
|
37
|
+
'cp1250': 'windows_1250',
|
|
38
|
+
'cp852': 'cp852',
|
|
39
|
+
"mac_iceland": "MAC_IS",
|
|
40
|
+
|
|
41
|
+
# --- Cyrillic ---
|
|
42
|
+
'iso-8859-5': 'iso_8859_5',
|
|
43
|
+
'iso_8859_5': 'iso_8859_5',
|
|
44
|
+
'cyrillic': 'iso_8859_5',
|
|
45
|
+
'windows-1251': 'windows_1251',
|
|
46
|
+
'cp1251': 'windows_1251',
|
|
47
|
+
'koi8-r': 'koi8_r',
|
|
48
|
+
'koi8_r': 'koi8_r',
|
|
49
|
+
|
|
50
|
+
# --- Greek ---
|
|
51
|
+
'iso-8859-7': 'iso_8859_7',
|
|
52
|
+
'iso_8859_7': 'iso_8859_7',
|
|
53
|
+
'windows-1253': 'windows_1253',
|
|
54
|
+
'cp1253': 'windows_1253',
|
|
55
|
+
|
|
56
|
+
# --- Japenese ---
|
|
57
|
+
'shift_jis': 'shift_jis',
|
|
58
|
+
'sjis': 'shift_jis',
|
|
59
|
+
'ibm-943': 'shift_jis',
|
|
60
|
+
'windows-932': 'shift_jis',
|
|
61
|
+
'euc-jp': 'euc_jp',
|
|
62
|
+
|
|
63
|
+
# --- Chinese ---
|
|
64
|
+
'gbk': 'gbk',
|
|
65
|
+
'gb2312': 'gb2312',
|
|
66
|
+
'big5': 'big5',
|
|
67
|
+
|
|
68
|
+
# --- Korean ---
|
|
69
|
+
'euc-kr': 'euc_kr',
|
|
70
|
+
'cp949': 'cp949',
|
|
71
|
+
'johab': 'johab',
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
ENCODINGS_UNDERSCORE_CONFLICT = {
|
|
75
|
+
'shift_jis',
|
|
76
|
+
'cp932',
|
|
77
|
+
'big5',
|
|
78
|
+
'gbk',
|
|
79
|
+
'gb2312',
|
|
80
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|