codec-bridge 0.1.0__tar.gz → 0.2.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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: codec_bridge
3
- Version: 0.1.0
3
+ Version: 0.2.0
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
@@ -34,6 +34,12 @@ Classifier: Operating System :: POSIX :: Linux
34
34
  Requires-Python: >=3.12
35
35
  Description-Content-Type: text/markdown
36
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
37
43
 
38
44
  # codec_bridge
39
45
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codec_bridge"
3
- version = "0.1.0"
3
+ version = "0.2.0"
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,14 +2,15 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='codec_bridge',
5
- version='0.1.0',
5
+ version='0.2.0',
6
+ packages=find_packages(where="src"),
7
+ package_dir={"": "src"},
6
8
  description='Encoding and case normalization bridge for DuckDB and other engines',
7
9
  long_description=open('README.md', encoding='utf-8').read(),
8
10
  long_description_content_type='text/markdown',
9
11
  author='João Pedro Ferraz Bezerra',
10
12
  author_email='jpferraz554@gmail.com',
11
13
  url='https://github.com/jpferraz-git/codec_bridge',
12
- packages=find_packages(),
13
14
  classifiers=[
14
15
  'Programming Language :: Python :: 3.12',
15
16
  'Operating System :: OS Independent',
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
2
- Name: codec-bridge
3
- Version: 0.1.0
1
+ Metadata-Version: 2.4
2
+ Name: codec_bridge
3
+ Version: 0.2.0
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
@@ -34,6 +34,12 @@ Classifier: Operating System :: POSIX :: Linux
34
34
  Requires-Python: >=3.12
35
35
  Description-Content-Type: text/markdown
36
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
37
43
 
38
44
  # codec_bridge
39
45
 
@@ -0,0 +1,11 @@
1
+ README.md
2
+ license.txt
3
+ pyproject.toml
4
+ setup.py
5
+ src/codec_bridge/__init__.py
6
+ src/codec_bridge/encoding_translator.py
7
+ src/codec_bridge.egg-info/PKG-INFO
8
+ src/codec_bridge.egg-info/SOURCES.txt
9
+ src/codec_bridge.egg-info/dependency_links.txt
10
+ src/codec_bridge.egg-info/requires.txt
11
+ src/codec_bridge.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ codec_bridge
@@ -1,16 +0,0 @@
1
- README.md
2
- license.txt
3
- pyproject.toml
4
- setup.py
5
- codec_bridge.egg-info/PKG-INFO
6
- codec_bridge.egg-info/SOURCES.txt
7
- codec_bridge.egg-info/dependency_links.txt
8
- codec_bridge.egg-info/requires.txt
9
- codec_bridge.egg-info/top_level.txt
10
- repository/__init__.py
11
- repository/python_to_duckdb.py
12
- src/__init__.py
13
- src/encoding_translator.py
14
- tests/__init__.py
15
- tests/duckdb_utils.py
16
- tests/generate_test_data.py
@@ -1,3 +0,0 @@
1
- repository
2
- src
3
- tests
@@ -1,80 +0,0 @@
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
@@ -1,21 +0,0 @@
1
- import os
2
- def create_table_from_csv(conn, file_path: str, table_name: str, delimiter: str = '|', encoding: str = "utf-8"):
3
- """
4
- Create a table on DuckDB
5
- """
6
- print(f"Processando '{os.path.basename(file_path)}': Tabela='{table_name}', Encoding='{encoding}', Delim='{delimiter}'")
7
- try:
8
- conn.sql(f"""
9
- CREATE OR REPLACE TEMP TABLE "{table_name}" AS
10
- (SELECT * FROM
11
- read_csv('{file_path}',
12
- delim='{delimiter}',
13
- encoding='{encoding}',
14
- header=true,
15
- auto_detect=true
16
- ) LIMIT 1000)
17
- """)
18
- print(f"✅ Tabela '{table_name}' criada com sucesso.")
19
- print(conn.sql(f'SELECT * FROM "{table_name}" LIMIT 3'))
20
- except Exception as e:
21
- print(f"❌ ERRO ao criar a tabela '{table_name}': {e}")
@@ -1,61 +0,0 @@
1
- import csv
2
- import os
3
-
4
-
5
- DEFAULT_OUTPUT_DIR = os.path.join(os.path.dirname(__file__), "assets")
6
-
7
- def generate_csv_test_files(output_dir: str = DEFAULT_OUTPUT_DIR, num_rows: int = 1000):
8
- """
9
- Generates a suite of CSV files with different encodings and characters
10
- to be used as assets for running tests.
11
- """
12
- os.makedirs(output_dir, exist_ok=True)
13
- print(f"Generating test files in: {output_dir}")
14
-
15
- encodings_to_test = [
16
- "utf-8", "utf-16", "iso-8859-1", "windows-1252",
17
- "ascii", "iso-8859-2", "iso-8859-5", "koi8-r",
18
- "shift_jis", "gbk", "big5", "windows-1253", "iso-8859-15"
19
- ]
20
-
21
- # Dictionary of "killer characters" to make each encoding unique
22
- special_chars = {
23
- "iso-8859-1": "ç",
24
- "windows-1252": "€",
25
- "iso-8859-2": "ść",
26
- "iso-8859-5": "ДЖ",
27
- "koi8-r": "ДЖ",
28
- "shift_jis": "ア",
29
- "gbk": "你好",
30
- "big5": "你好",
31
- "windows-1253": "αβ",
32
- "iso-8859-15": "€",
33
- "utf-8": "🚀",
34
- "utf-16": "🚀",
35
- }
36
-
37
- def generate_rows(example_char=""):
38
- # Add the special character to the first cell of each row
39
- return [[f"Data_{i}_{j}{example_char if j == 0 else ''}" for j in range(10)] for i in range(num_rows)]
40
-
41
- # Loop through encodings and generate files
42
- for enc in encodings_to_test:
43
- filename = os.path.join(output_dir, f"test_{enc}.csv")
44
- special_char = special_chars.get(enc, "")
45
- rows = generate_rows(special_char)
46
-
47
- try:
48
- with open(filename, mode="w", encoding=enc, newline="") as file:
49
- writer = csv.writer(file)
50
- writer.writerow(["Header_1", "Header_2", "Header_3", "Header_4", "Header_5"])
51
- writer.writerows(rows)
52
- print(f"✅ Generated: {os.path.basename(filename)} (with char: '{special_char}')")
53
- except UnicodeEncodeError:
54
- print(f"❌ Encoding Error with {enc}: The character '{special_char}' is not supported.")
55
- except Exception as e:
56
- print(f"⚠️ Unexpected Error with {enc}: {e}")
57
-
58
- if __name__ == "__main__":
59
- # This allows you to run the script directly to generate the files
60
- # python tests/generate_test_data.py
61
- generate_csv_test_files()
File without changes
File without changes
File without changes