csv-detective 0.9.3.dev2241__py3-none-any.whl → 0.9.3.dev2258__py3-none-any.whl

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.
@@ -12,19 +12,17 @@ def detect_headers(file: TextIO, sep: str, verbose: bool = False) -> tuple[int,
12
12
  logging.info("Detecting headers")
13
13
  file.seek(0)
14
14
  for i in range(10):
15
- header = file.readline()
15
+ row = file.readline()
16
16
  position = file.tell()
17
- chaine = [c for c in header.replace("\n", "").split(sep) if c]
18
- if chaine[-1] not in ["", "\n"] and all([mot not in ["", "\n"] for mot in chaine[1:-1]]):
17
+ headers = [c for c in row.replace("\n", "").split(sep) if c]
18
+ if not any(col == "" for col in headers):
19
19
  next_row = file.readline()
20
20
  file.seek(position)
21
- if header != next_row:
21
+ if row != next_row:
22
22
  if verbose:
23
23
  display_logs_depending_process_time(
24
24
  f"Detected headers in {round(time() - start, 3)}s",
25
25
  time() - start,
26
26
  )
27
- return i, chaine
28
- if verbose:
29
- logging.info("No header detected")
30
- return 0, None
27
+ return i, headers
28
+ raise ValueError("Could not retrieve headers")
@@ -47,6 +47,8 @@ def load_file(
47
47
  if table.empty:
48
48
  raise ValueError("Table seems to be empty")
49
49
  header = table.columns.to_list()
50
+ if any(col.startswith("Unnamed") for col in header):
51
+ raise ValueError("Could not retrieve headers")
50
52
  analysis = {
51
53
  "engine": engine,
52
54
  "sheet_name": sheet_name,
@@ -99,12 +101,10 @@ def load_file(
99
101
  }
100
102
  if engine is not None:
101
103
  analysis["compression"] = engine
102
- analysis.update(
103
- {
104
- "header_row_idx": header_row_idx,
105
- "header": header,
106
- }
107
- )
104
+ analysis |= {
105
+ "header_row_idx": header_row_idx,
106
+ "header": header,
107
+ }
108
108
  if total_lines is not None:
109
109
  analysis["total_lines"] = total_lines
110
110
  if nb_duplicates is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: csv-detective
3
- Version: 0.9.3.dev2241
3
+ Version: 0.9.3.dev2258
4
4
  Summary: Detect tabular files column content
5
5
  Author-email: Etalab <opendatateam@data.gouv.fr>
6
6
  License: MIT
@@ -132,7 +132,7 @@ csv_detective/detection/columns.py,sha256=_JtZHBr3aoEmSWh2xVe2ISnt-G7hpnA9vqlvca
132
132
  csv_detective/detection/encoding.py,sha256=KZ8W8BPfZAq9UiP5wgaeupYa5INU8KPz98E2L3XpX2Y,999
133
133
  csv_detective/detection/engine.py,sha256=wQeDKpp2DKF-HcS1R8H6GgQyaUgQme4szPtEHgAjBII,1552
134
134
  csv_detective/detection/formats.py,sha256=92ZZafoJFZHDSxSUR6rDCFjLGpD4f4IZorqqVgxwFY8,5595
135
- csv_detective/detection/headers.py,sha256=hvYU13Nq8GWci5skc5vVUOxM0DwOUwbjVMlmY94lWhA,1135
135
+ csv_detective/detection/headers.py,sha256=95pTL524Sy5PGxyQ03ofFUaamvlmkxTJQe8u6HfzOkU,1051
136
136
  csv_detective/detection/rows.py,sha256=quf3ZTTFPOo09H-faZ9cRKibb1QGHEKHlpivFRx2Va4,742
137
137
  csv_detective/detection/separator.py,sha256=XjeDBqhiBxVfkCPJKem9BAgJqs_hOgQltc_pxrH_-Tg,1547
138
138
  csv_detective/detection/variables.py,sha256=-QtZOB96z3pWbqnZ-c1RU3yzoYqcO61A0JzeS6JbkxY,3576
@@ -147,9 +147,9 @@ csv_detective/parsing/columns.py,sha256=X5v3_1zgZXadnxjUG3__xLjOIvNU4n9LOiWZbix4
147
147
  csv_detective/parsing/compression.py,sha256=Fnw5tj-PpBNI8NYsWj5gD-DUoWcVLnsVpiKm9MpxmIA,350
148
148
  csv_detective/parsing/csv.py,sha256=BJ_fqoCCCCSJ61uHyiEpDmXlBdrqWLY-UKtKwkYw65c,1742
149
149
  csv_detective/parsing/excel.py,sha256=oAVTuoDccJc4-kVjHXiIPLQx3lq3aZRRZQxkG1c06JQ,6992
150
- csv_detective/parsing/load.py,sha256=Ks1S92H_GErvd2Uy0_EuShMzZSkiuWdTmVQFJ_XX5lg,4167
150
+ csv_detective/parsing/load.py,sha256=EHVWQqV9TmWOiVNLCyHr9V8x4PI_53O0iTVluzIqw78,4256
151
151
  csv_detective/parsing/text.py,sha256=uz8wfmNTQnOd_4fjrIZ_5rxmFmgrg343hJh2szB73Hc,1770
152
- csv_detective-0.9.3.dev2241.dist-info/licenses/LICENSE,sha256=A1dQrzxyxRHRih02KwibWj1khQyF7GeA6SqdOU87Gk4,1088
152
+ csv_detective-0.9.3.dev2258.dist-info/licenses/LICENSE,sha256=A1dQrzxyxRHRih02KwibWj1khQyF7GeA6SqdOU87Gk4,1088
153
153
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
154
154
  tests/test_example.py,sha256=uTWswvUzBWEADGXZmMAdZvKhKvIjvT5zWOVVABgCDN4,1987
155
155
  tests/test_fields.py,sha256=QoMsVR-ZhH5F9DFqYDvzP6vQCZcoalEi8JBb_fxWR44,13665
@@ -159,8 +159,8 @@ tests/test_structure.py,sha256=KGpw45weVK3iEWAg3OVHHEbj7RYALFicnZ59z7rCFuU,1450
159
159
  tests/test_validation.py,sha256=9djBT-PDhu_563OFgWyE20o-wPEWEIQGXp6Pjh0_MQM,3463
160
160
  venv/bin/activate_this.py,sha256=wS7qPipy8R-dS_0ICD8PqqUQ8F-PrtcpiJw2DUPngYM,1287
161
161
  venv/bin/runxlrd.py,sha256=YlZMuycM_V_hzNt2yt3FyXPuwouMCmMhvj1oZaBeeuw,16092
162
- csv_detective-0.9.3.dev2241.dist-info/METADATA,sha256=Cy0R4v1C7Lg-KRgD1_pBP4uO_huMU0158VorSXw8b2w,10845
163
- csv_detective-0.9.3.dev2241.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
164
- csv_detective-0.9.3.dev2241.dist-info/entry_points.txt,sha256=JjweTReFqKJmuvkegzlew2j3D5pZzfxvbEGOtGVGmaY,56
165
- csv_detective-0.9.3.dev2241.dist-info/top_level.txt,sha256=cYKb4Ok3XgYA7rMDOYtxysjSJp_iUA9lJjynhVzue8g,30
166
- csv_detective-0.9.3.dev2241.dist-info/RECORD,,
162
+ csv_detective-0.9.3.dev2258.dist-info/METADATA,sha256=gGV63RWaQSVUSaJl24mR9Ynk2BOV1tK6LWyNsq-AYkA,10845
163
+ csv_detective-0.9.3.dev2258.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
164
+ csv_detective-0.9.3.dev2258.dist-info/entry_points.txt,sha256=JjweTReFqKJmuvkegzlew2j3D5pZzfxvbEGOtGVGmaY,56
165
+ csv_detective-0.9.3.dev2258.dist-info/top_level.txt,sha256=cYKb4Ok3XgYA7rMDOYtxysjSJp_iUA9lJjynhVzue8g,30
166
+ csv_detective-0.9.3.dev2258.dist-info/RECORD,,