csv-detective 0.9.3.dev2052__py3-none-any.whl → 0.9.3.dev2090__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.
@@ -6,19 +6,20 @@ from csv_detective.detect_fields.temp.date import aaaammjj_pattern, date_casting
6
6
  PROPORTION = 1
7
7
  threshold = 0.7
8
8
 
9
- # matches AAAA-MM-JJTHH:MM:SS(.dddddd)±HH:MM with any of the listed separators for the date OR NO SEPARATOR
9
+ # matches AAAA-MM-JJTHH:MM:SS(.dddddd)(±HH:MM|Z) with any of the listed separators for the date OR NO SEPARATOR
10
10
  pat = (
11
11
  aaaammjj_pattern.replace("$", "")
12
- + r"(T|\s)(0\d|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(.\d{1,6})?[+-](0\d|1[0-9]|2[0-3]):([0-5][0-9])$"
12
+ + r"(T|\s)(0\d|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(.\d{1,6})"
13
+ + r"?(([+-](0\d|1[0-9]|2[0-3]):([0-5][0-9]))|Z)$"
13
14
  )
14
15
 
15
16
 
16
17
  def _is(val: Optional[Any]) -> bool:
17
18
  """Detects timezone-aware datetimes only"""
18
19
  # early stops, to cut processing time
19
- # 21 is the minimal length of a datetime format YYMMDDTHH:MM:SS+HH:MM
20
+ # 16 is the minimal length of a datetime format YYMMDDTHH:MM:SSZ
20
21
  # 32 is the maximal length of an ISO datetime format YYYY-MM-DDTHH:MM:SS.dddddd+HH:MM, keeping some slack
21
- if not isinstance(val, str) or len(val) > 35 or len(val) < 21:
22
+ if not isinstance(val, str) or len(val) > 35 or len(val) < 16:
22
23
  return False
23
24
  # if usual format, no need to parse
24
25
  if bool(re.match(pat, val)):
@@ -9,7 +9,7 @@ threshold = 0.7
9
9
  # matches AAAA-MM-JJTHH:MM:SS(.dddddd)Z with any of the listed separators for the date OR NO SEPARATOR
10
10
  pat = (
11
11
  aaaammjj_pattern.replace("$", "")
12
- + r"(T|\s)(0\d|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(.\d{1,6})?Z?$"
12
+ + r"(T|\s)(0\d|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(.\d{1,6})?$"
13
13
  )
14
14
 
15
15
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: csv-detective
3
- Version: 0.9.3.dev2052
3
+ Version: 0.9.3.dev2090
4
4
  Summary: Detect tabular files column content
5
5
  Author-email: Etalab <opendatateam@data.gouv.fr>
6
6
  License: MIT
@@ -67,8 +67,8 @@ csv_detective/detect_fields/other/url/__init__.py,sha256=L7h9fZldh1w86XwCx0x3Q1T
67
67
  csv_detective/detect_fields/other/uuid/__init__.py,sha256=XFxbIsdIhRw0dtFxBXQBhicE4yy7P4jmwYXeJhq6FVY,215
68
68
  csv_detective/detect_fields/temp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
69
69
  csv_detective/detect_fields/temp/date/__init__.py,sha256=JtWaK8hkzBaIUc-fu0G7lIFpWqCfraRh6l0Mo65U3b0,2155
70
- csv_detective/detect_fields/temp/datetime_aware/__init__.py,sha256=ZDNUcbU0ZJzaxUt0Utc1Y9dRrq4HHW9uCbcnOuz5Sfk,1247
71
- csv_detective/detect_fields/temp/datetime_naive/__init__.py,sha256=U1mlQdbvEeJNZgMiYY7xv-_EIBRqzxHsKUgU3ZoF0FM,1088
70
+ csv_detective/detect_fields/temp/datetime_aware/__init__.py,sha256=TV-Bden-3SFm9RPBtem1biqoxyEjsshZm9fFbnNXAIY,1263
71
+ csv_detective/detect_fields/temp/datetime_naive/__init__.py,sha256=kodVtLa9ZBy7eJDNo2PQOdgoTXlXkVTUN8Vk03lG1n0,1086
72
72
  csv_detective/detect_fields/temp/datetime_rfc822/__init__.py,sha256=-pFdIIPgaLq2_QbFJ9zwy4YIwZuC73F0A_cNDntTuvQ,512
73
73
  csv_detective/detect_fields/temp/year/__init__.py,sha256=gHchVciZExbGZLMBcbBaDXB0IgGptkQc4RhfSOMY0Ww,194
74
74
  csv_detective/detect_labels/__init__.py,sha256=93s93DRNeFw9fJiGp0rW3iRWZX3WOeVau2PAaF4QlPE,1777
@@ -149,18 +149,18 @@ csv_detective/parsing/csv.py,sha256=fJkjKvyk7InkNnYKtmivyi48mmcwvrha7gvZ5J4-86A,
149
149
  csv_detective/parsing/excel.py,sha256=sKD5PRN1TlzPPOKFnZ3VRb0r1yIjPLlpxVWmZQeLYFk,7027
150
150
  csv_detective/parsing/load.py,sha256=C3M8nvgWenOb8aDFi5dpDGCoAw9EBqr4EB63zbz2M14,3699
151
151
  csv_detective/parsing/text.py,sha256=uz8wfmNTQnOd_4fjrIZ_5rxmFmgrg343hJh2szB73Hc,1770
152
- csv_detective-0.9.3.dev2052.dist-info/licenses/LICENSE,sha256=A1dQrzxyxRHRih02KwibWj1khQyF7GeA6SqdOU87Gk4,1088
152
+ csv_detective-0.9.3.dev2090.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
- tests/test_fields.py,sha256=IjUvDz155fl0XRw2ENEy5j_auyB3LTidXFi1bEWOCHg,13725
155
+ tests/test_fields.py,sha256=R6r6dcUwPx9XWIoc1xH4z0HlCnTj_bmxw91H5Gfqq5I,13762
156
156
  tests/test_file.py,sha256=QEBv69P0bAKWBzhQ3KKOR1Z1RQSf5CVEilqBojwP2Yc,10791
157
157
  tests/test_labels.py,sha256=Y0XlOpztCyV65pk7iAS_nMMfdysoBujlBmz10vHul9A,469
158
158
  tests/test_structure.py,sha256=GRDYKy0UcdqlN4qglzsRC0puFj5cb-SVvONjvcPvtAA,1400
159
159
  tests/test_validation.py,sha256=ie-Xf0vk6-M6GQq-x7kY5yse1EmXfxQkbaV7fR3fvYo,3308
160
160
  venv/bin/activate_this.py,sha256=NRy3waFmwW1pOaNUp33wNN0vD1Kzkd-zXX-Sgl4EiVI,1286
161
161
  venv/bin/runxlrd.py,sha256=YlZMuycM_V_hzNt2yt3FyXPuwouMCmMhvj1oZaBeeuw,16092
162
- csv_detective-0.9.3.dev2052.dist-info/METADATA,sha256=Kn9PGSyDQEZfC9cFHyAB_nyyUupDB45IGnz2Ec2RktE,9735
163
- csv_detective-0.9.3.dev2052.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
164
- csv_detective-0.9.3.dev2052.dist-info/entry_points.txt,sha256=JjweTReFqKJmuvkegzlew2j3D5pZzfxvbEGOtGVGmaY,56
165
- csv_detective-0.9.3.dev2052.dist-info/top_level.txt,sha256=cYKb4Ok3XgYA7rMDOYtxysjSJp_iUA9lJjynhVzue8g,30
166
- csv_detective-0.9.3.dev2052.dist-info/RECORD,,
162
+ csv_detective-0.9.3.dev2090.dist-info/METADATA,sha256=nxz1XUFLoP5x9PTp8b0QHFOaH0Rz1mqITXd_zi-SbpY,9735
163
+ csv_detective-0.9.3.dev2090.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
164
+ csv_detective-0.9.3.dev2090.dist-info/entry_points.txt,sha256=JjweTReFqKJmuvkegzlew2j3D5pZzfxvbEGOtGVGmaY,56
165
+ csv_detective-0.9.3.dev2090.dist-info/top_level.txt,sha256=cYKb4Ok3XgYA7rMDOYtxysjSJp_iUA9lJjynhVzue8g,30
166
+ csv_detective-0.9.3.dev2090.dist-info/RECORD,,
tests/test_fields.py CHANGED
@@ -357,6 +357,7 @@ fields = {
357
357
  True: [
358
358
  "2021-06-22 10:20:10-04:00",
359
359
  "2030-06-22 00:00:00.0028+02:00",
360
+ "2000-12-21 10:20:10.1Z",
360
361
  "2024-12-19T10:53:36.428000+00:00",
361
362
  "1996/06/22 10:20:10 GMT",
362
363
  ],
@@ -365,7 +366,6 @@ fields = {
365
366
  datetime_naive: {
366
367
  True: [
367
368
  "2021-06-22 10:20:10",
368
- "1999-12-01T00:00:00Z",
369
369
  "2030/06-22 00:00:00",
370
370
  "2030/06/22 00:00:00.0028",
371
371
  ],
@@ -373,6 +373,7 @@ fields = {
373
373
  "2021-06-22T30:20:10",
374
374
  "Sun, 06 Nov 1994 08:49:37 GMT",
375
375
  "2021-06-44 10:20:10+02:00",
376
+ "1999-12-01T00:00:00Z",
376
377
  "2021-06-44",
377
378
  "15 décembre 1985",
378
379
  ],
@@ -459,8 +460,8 @@ def test_priority(args):
459
460
  ("28/01/2000", date),
460
461
  ("2025-08-20T14:30:00+02:00", datetime_aware),
461
462
  ("2025/08/20 14:30:00.2763-12:00", datetime_aware),
462
- ("1925_12_20T14:30:00.2763Z", datetime_naive),
463
- ("1925 12 20 14:30:00Z", datetime_naive),
463
+ ("1925_12_20T14:30:00.2763", datetime_naive),
464
+ ("1925 12 20 14:30:00Z", datetime_aware),
464
465
  ),
465
466
  )
466
467
  def test_early_detection(args):