sister-software-spliterator 11.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 (29) hide show
  1. sister_software_spliterator-11.0.0/Cargo.lock +388 -0
  2. sister_software_spliterator-11.0.0/Cargo.toml +14 -0
  3. sister_software_spliterator-11.0.0/LICENSE.md +21 -0
  4. sister_software_spliterator-11.0.0/PKG-INFO +89 -0
  5. sister_software_spliterator-11.0.0/README.md +69 -0
  6. sister_software_spliterator-11.0.0/crates/spliterator/Cargo.toml +37 -0
  7. sister_software_spliterator-11.0.0/crates/spliterator/LICENSE.md +21 -0
  8. sister_software_spliterator-11.0.0/crates/spliterator/README.md +43 -0
  9. sister_software_spliterator-11.0.0/crates/spliterator/src/csv.rs +590 -0
  10. sister_software_spliterator-11.0.0/crates/spliterator/src/error.rs +67 -0
  11. sister_software_spliterator-11.0.0/crates/spliterator/src/jsonl.rs +164 -0
  12. sister_software_spliterator-11.0.0/crates/spliterator/src/keys.rs +143 -0
  13. sister_software_spliterator-11.0.0/crates/spliterator/src/lib.rs +33 -0
  14. sister_software_spliterator-11.0.0/crates/spliterator/src/records.rs +346 -0
  15. sister_software_spliterator-11.0.0/crates/spliterator/src/source.rs +188 -0
  16. sister_software_spliterator-11.0.0/crates/spliterator/src/text.rs +223 -0
  17. sister_software_spliterator-11.0.0/crates/spliterator/src/whitespace.rs +48 -0
  18. sister_software_spliterator-11.0.0/crates/spliterator-py/Cargo.toml +19 -0
  19. sister_software_spliterator-11.0.0/crates/spliterator-py/LICENSE.md +21 -0
  20. sister_software_spliterator-11.0.0/crates/spliterator-py/README.md +69 -0
  21. sister_software_spliterator-11.0.0/crates/spliterator-py/src/lib.rs +585 -0
  22. sister_software_spliterator-11.0.0/crates/spliterator-py/tests/test_conformance.py +191 -0
  23. sister_software_spliterator-11.0.0/crates/spliterator-py/tests/test_sources.py +158 -0
  24. sister_software_spliterator-11.0.0/pyproject.toml +50 -0
  25. sister_software_spliterator-11.0.0/python/spliterator/__init__.py +505 -0
  26. sister_software_spliterator-11.0.0/python/spliterator/_errors.py +49 -0
  27. sister_software_spliterator-11.0.0/python/spliterator/_native.pyi +89 -0
  28. sister_software_spliterator-11.0.0/python/spliterator/_types.py +16 -0
  29. sister_software_spliterator-11.0.0/python/spliterator/py.typed +0 -0
@@ -0,0 +1,388 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "adler2"
7
+ version = "2.0.1"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
10
+
11
+ [[package]]
12
+ name = "aho-corasick"
13
+ version = "1.1.5"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba"
16
+ dependencies = [
17
+ "memchr",
18
+ ]
19
+
20
+ [[package]]
21
+ name = "base64"
22
+ version = "0.22.1"
23
+ source = "registry+https://github.com/rust-lang/crates.io-index"
24
+ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
25
+
26
+ [[package]]
27
+ name = "cc"
28
+ version = "1.10.0"
29
+ source = "registry+https://github.com/rust-lang/crates.io-index"
30
+ checksum = "86e055fa6e3e40ad6187ba25b6855eeb635d5271f8e0f0e1e9a5826b8d75bea0"
31
+ dependencies = [
32
+ "find-msvc-tools",
33
+ "jobserver",
34
+ "libc",
35
+ "shlex",
36
+ ]
37
+
38
+ [[package]]
39
+ name = "cfg-if"
40
+ version = "1.0.5"
41
+ source = "registry+https://github.com/rust-lang/crates.io-index"
42
+ checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
43
+
44
+ [[package]]
45
+ name = "crc32fast"
46
+ version = "1.5.3"
47
+ source = "registry+https://github.com/rust-lang/crates.io-index"
48
+ checksum = "0ba106e844045ddc02c20768ac4b0b7cb45f2cc2ecbd833ac9f5dacb183c2055"
49
+ dependencies = [
50
+ "cfg-if",
51
+ ]
52
+
53
+ [[package]]
54
+ name = "find-msvc-tools"
55
+ version = "0.1.15"
56
+ source = "registry+https://github.com/rust-lang/crates.io-index"
57
+ checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48"
58
+
59
+ [[package]]
60
+ name = "flate2"
61
+ version = "1.1.10"
62
+ source = "registry+https://github.com/rust-lang/crates.io-index"
63
+ checksum = "6e634e2e0ebac1ee034020da1ca582e17ffe4e0f5e985823721e168928136dcb"
64
+ dependencies = [
65
+ "crc32fast",
66
+ "miniz_oxide",
67
+ "zlib-rs",
68
+ ]
69
+
70
+ [[package]]
71
+ name = "getrandom"
72
+ version = "0.4.3"
73
+ source = "registry+https://github.com/rust-lang/crates.io-index"
74
+ checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
75
+ dependencies = [
76
+ "cfg-if",
77
+ "libc",
78
+ "r-efi",
79
+ ]
80
+
81
+ [[package]]
82
+ name = "heck"
83
+ version = "0.5.0"
84
+ source = "registry+https://github.com/rust-lang/crates.io-index"
85
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
86
+
87
+ [[package]]
88
+ name = "itoa"
89
+ version = "1.0.18"
90
+ source = "registry+https://github.com/rust-lang/crates.io-index"
91
+ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
92
+
93
+ [[package]]
94
+ name = "jobserver"
95
+ version = "0.1.35"
96
+ source = "registry+https://github.com/rust-lang/crates.io-index"
97
+ checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3"
98
+ dependencies = [
99
+ "getrandom",
100
+ "libc",
101
+ ]
102
+
103
+ [[package]]
104
+ name = "libc"
105
+ version = "0.2.191"
106
+ source = "registry+https://github.com/rust-lang/crates.io-index"
107
+ checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
108
+
109
+ [[package]]
110
+ name = "memchr"
111
+ version = "2.8.3"
112
+ source = "registry+https://github.com/rust-lang/crates.io-index"
113
+ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
114
+
115
+ [[package]]
116
+ name = "miniz_oxide"
117
+ version = "0.9.1"
118
+ source = "registry+https://github.com/rust-lang/crates.io-index"
119
+ checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c"
120
+ dependencies = [
121
+ "adler2",
122
+ "simd-adler32",
123
+ ]
124
+
125
+ [[package]]
126
+ name = "once_cell"
127
+ version = "1.21.4"
128
+ source = "registry+https://github.com/rust-lang/crates.io-index"
129
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
130
+
131
+ [[package]]
132
+ name = "pkg-config"
133
+ version = "0.3.34"
134
+ source = "registry+https://github.com/rust-lang/crates.io-index"
135
+ checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"
136
+
137
+ [[package]]
138
+ name = "portable-atomic"
139
+ version = "1.15.0"
140
+ source = "registry+https://github.com/rust-lang/crates.io-index"
141
+ checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
142
+
143
+ [[package]]
144
+ name = "proc-macro2"
145
+ version = "1.0.107"
146
+ source = "registry+https://github.com/rust-lang/crates.io-index"
147
+ checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
148
+ dependencies = [
149
+ "unicode-ident",
150
+ ]
151
+
152
+ [[package]]
153
+ name = "pyo3"
154
+ version = "0.30.1"
155
+ source = "registry+https://github.com/rust-lang/crates.io-index"
156
+ checksum = "229ca13b8a15bb0d1487b81ab975bfcd97513416499a8312011b6036e42e0de4"
157
+ dependencies = [
158
+ "libc",
159
+ "once_cell",
160
+ "portable-atomic",
161
+ "pyo3-build-config",
162
+ "pyo3-ffi",
163
+ "pyo3-macros",
164
+ ]
165
+
166
+ [[package]]
167
+ name = "pyo3-build-config"
168
+ version = "0.30.1"
169
+ source = "registry+https://github.com/rust-lang/crates.io-index"
170
+ checksum = "70130e2b6dd1ee589a8788026a429561ca5c40fa7a2fa7914c2282eddae24700"
171
+ dependencies = [
172
+ "target-lexicon",
173
+ ]
174
+
175
+ [[package]]
176
+ name = "pyo3-ffi"
177
+ version = "0.30.1"
178
+ source = "registry+https://github.com/rust-lang/crates.io-index"
179
+ checksum = "5e7ff73c555c286d212d4ce7e5fbda845a973c4f61bd5f160f5f2c3c2a04d1c4"
180
+ dependencies = [
181
+ "libc",
182
+ "pyo3-build-config",
183
+ ]
184
+
185
+ [[package]]
186
+ name = "pyo3-macros"
187
+ version = "0.30.1"
188
+ source = "registry+https://github.com/rust-lang/crates.io-index"
189
+ checksum = "c46d2e5862c7bb8207e3b639f713dda3c499933444784154c11d013c5a691b60"
190
+ dependencies = [
191
+ "proc-macro2",
192
+ "pyo3-macros-backend",
193
+ "quote",
194
+ "syn",
195
+ ]
196
+
197
+ [[package]]
198
+ name = "pyo3-macros-backend"
199
+ version = "0.30.1"
200
+ source = "registry+https://github.com/rust-lang/crates.io-index"
201
+ checksum = "38b89f066f2ae72a2aef52d1537ca2fcd104440ebfadee06e97aa90738a25b9b"
202
+ dependencies = [
203
+ "heck",
204
+ "proc-macro2",
205
+ "quote",
206
+ "syn",
207
+ ]
208
+
209
+ [[package]]
210
+ name = "quote"
211
+ version = "1.0.47"
212
+ source = "registry+https://github.com/rust-lang/crates.io-index"
213
+ checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
214
+ dependencies = [
215
+ "proc-macro2",
216
+ ]
217
+
218
+ [[package]]
219
+ name = "r-efi"
220
+ version = "6.0.0"
221
+ source = "registry+https://github.com/rust-lang/crates.io-index"
222
+ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
223
+
224
+ [[package]]
225
+ name = "regex"
226
+ version = "1.13.1"
227
+ source = "registry+https://github.com/rust-lang/crates.io-index"
228
+ checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
229
+ dependencies = [
230
+ "aho-corasick",
231
+ "memchr",
232
+ "regex-automata",
233
+ "regex-syntax",
234
+ ]
235
+
236
+ [[package]]
237
+ name = "regex-automata"
238
+ version = "0.4.18"
239
+ source = "registry+https://github.com/rust-lang/crates.io-index"
240
+ checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
241
+ dependencies = [
242
+ "aho-corasick",
243
+ "memchr",
244
+ "regex-syntax",
245
+ ]
246
+
247
+ [[package]]
248
+ name = "regex-syntax"
249
+ version = "0.8.11"
250
+ source = "registry+https://github.com/rust-lang/crates.io-index"
251
+ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
252
+
253
+ [[package]]
254
+ name = "serde"
255
+ version = "1.0.229"
256
+ source = "registry+https://github.com/rust-lang/crates.io-index"
257
+ checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
258
+ dependencies = [
259
+ "serde_core",
260
+ ]
261
+
262
+ [[package]]
263
+ name = "serde_core"
264
+ version = "1.0.229"
265
+ source = "registry+https://github.com/rust-lang/crates.io-index"
266
+ checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
267
+ dependencies = [
268
+ "serde_derive",
269
+ ]
270
+
271
+ [[package]]
272
+ name = "serde_derive"
273
+ version = "1.0.229"
274
+ source = "registry+https://github.com/rust-lang/crates.io-index"
275
+ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
276
+ dependencies = [
277
+ "proc-macro2",
278
+ "quote",
279
+ "syn",
280
+ ]
281
+
282
+ [[package]]
283
+ name = "serde_json"
284
+ version = "1.0.154"
285
+ source = "registry+https://github.com/rust-lang/crates.io-index"
286
+ checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
287
+ dependencies = [
288
+ "itoa",
289
+ "memchr",
290
+ "serde",
291
+ "serde_core",
292
+ "zmij",
293
+ ]
294
+
295
+ [[package]]
296
+ name = "shlex"
297
+ version = "2.0.1"
298
+ source = "registry+https://github.com/rust-lang/crates.io-index"
299
+ checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
300
+
301
+ [[package]]
302
+ name = "simd-adler32"
303
+ version = "0.3.10"
304
+ source = "registry+https://github.com/rust-lang/crates.io-index"
305
+ checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea"
306
+
307
+ [[package]]
308
+ name = "spliterator"
309
+ version = "11.0.0"
310
+ dependencies = [
311
+ "base64",
312
+ "flate2",
313
+ "memchr",
314
+ "regex",
315
+ "serde_json",
316
+ "zstd",
317
+ ]
318
+
319
+ [[package]]
320
+ name = "spliterator-py"
321
+ version = "11.0.0"
322
+ dependencies = [
323
+ "pyo3",
324
+ "spliterator",
325
+ ]
326
+
327
+ [[package]]
328
+ name = "syn"
329
+ version = "3.0.9"
330
+ source = "registry+https://github.com/rust-lang/crates.io-index"
331
+ checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
332
+ dependencies = [
333
+ "proc-macro2",
334
+ "quote",
335
+ "unicode-ident",
336
+ ]
337
+
338
+ [[package]]
339
+ name = "target-lexicon"
340
+ version = "0.13.5"
341
+ source = "registry+https://github.com/rust-lang/crates.io-index"
342
+ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
343
+
344
+ [[package]]
345
+ name = "unicode-ident"
346
+ version = "1.0.27"
347
+ source = "registry+https://github.com/rust-lang/crates.io-index"
348
+ checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
349
+
350
+ [[package]]
351
+ name = "zlib-rs"
352
+ version = "0.6.8"
353
+ source = "registry+https://github.com/rust-lang/crates.io-index"
354
+ checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112"
355
+
356
+ [[package]]
357
+ name = "zmij"
358
+ version = "1.0.23"
359
+ source = "registry+https://github.com/rust-lang/crates.io-index"
360
+ checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
361
+
362
+ [[package]]
363
+ name = "zstd"
364
+ version = "0.14.3"
365
+ source = "registry+https://github.com/rust-lang/crates.io-index"
366
+ checksum = "db3ae9bf90af6e40197bef767eeefc46ad6397420fe873830bd85e5fbbfb3c70"
367
+ dependencies = [
368
+ "zstd-safe",
369
+ ]
370
+
371
+ [[package]]
372
+ name = "zstd-safe"
373
+ version = "8.2.0"
374
+ source = "registry+https://github.com/rust-lang/crates.io-index"
375
+ checksum = "ded520f16b29e1a9b771c722221b2b0a0398c2316d9bb3c42b458a5414d7434b"
376
+ dependencies = [
377
+ "zstd-sys",
378
+ ]
379
+
380
+ [[package]]
381
+ name = "zstd-sys"
382
+ version = "2.1.2+zstd.1.5.7"
383
+ source = "registry+https://github.com/rust-lang/crates.io-index"
384
+ checksum = "481ada9c543b2323cbb7bbdbb5249177fbf0188ed959ed2c15e4b22421c84ed3"
385
+ dependencies = [
386
+ "cc",
387
+ "pkg-config",
388
+ ]
@@ -0,0 +1,14 @@
1
+ [workspace]
2
+ resolver = "2"
3
+ members = ["crates/spliterator", "crates/spliterator-py"]
4
+ # The WASM SIMD kernel targets wasm32 only and builds on its own (wasm/build.sh).
5
+ exclude = ["wasm"]
6
+
7
+ [workspace.package]
8
+ version = "11.0.0"
9
+ edition = "2021"
10
+ rust-version = "1.85"
11
+ license = "MIT"
12
+ authors = ["Teffen Ellis <teffen@sister.software>"]
13
+ repository = "https://github.com/sister-software/spliterator"
14
+ homepage = "https://github.com/sister-software/spliterator"
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Teffen Ellis, Sister Software
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.
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.4
2
+ Name: sister-software-spliterator
3
+ Version: 11.0.0
4
+ Classifier: Programming Language :: Python :: 3
5
+ Classifier: Programming Language :: Rust
6
+ Classifier: Topic :: Text Processing
7
+ Classifier: Typing :: Typed
8
+ Requires-Dist: pytest>=8 ; extra == 'dev'
9
+ Provides-Extra: dev
10
+ License-File: LICENSE.md
11
+ Summary: Streaming readers for delimited text, CSV, TSV and JSONL with transparent zstd/gzip decompression, sharing the spliterator npm package's semantics.
12
+ Keywords: csv,jsonl,tsv,streaming,delimited,zstd
13
+ Author-email: Teffen Ellis <teffen@sister.software>
14
+ License-Expression: MIT
15
+ Requires-Python: >=3.11
16
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
17
+ Project-URL: Homepage, https://github.com/sister-software/spliterator
18
+ Project-URL: Repository, https://github.com/sister-software/spliterator
19
+
20
+ # spliterator (Python)
21
+
22
+ ```sh
23
+ pip install sister-software-spliterator
24
+ ```
25
+
26
+ The distribution is `sister-software-spliterator`; the import name is `spliterator`.
27
+
28
+ Streaming readers for delimited text, CSV, TSV, PSV and JSONL, with transparent zstd and gzip decompression.
29
+
30
+ This is the Python counterpart of the [`spliterator`](https://www.npmjs.com/package/spliterator) npm package and the
31
+ [`spliterator`](https://crates.io/crates/spliterator) Rust crate. All three read the same input into the same rows:
32
+ the same defaults, the same trimming, the same quote rules and the same errors. A shared conformance suite holds them
33
+ to it.
34
+
35
+ ```python
36
+ import spliterator
37
+
38
+ for row in spliterator.read_csv("people.csv"): # {"Full Name": "Ada", "Age": "36"}
39
+ ...
40
+
41
+ for value in spliterator.read_jsonl("part-0000.jsonl"): # reads part-0000.jsonl.zst when it exists
42
+ ...
43
+
44
+ for line in spliterator.read_text(b" a \n\n b\n"): # "a", "b"
45
+ ...
46
+ ```
47
+
48
+ ## Async and counts
49
+
50
+ Each reader has an async twin that reads each batch on a worker thread, so the event loop never blocks on I/O:
51
+
52
+ ```python
53
+ async for row in spliterator.aread_csv("people.csv"):
54
+ ...
55
+ ```
56
+
57
+ `count_text`, `count_csv`, `count_tsv` and `count_psv` return the number of rows the matching reader would yield,
58
+ without building them.
59
+
60
+ ## Sources
61
+
62
+ A source is a path (`str` or `os.PathLike`), bytes-like data, or a binary file object.
63
+
64
+ - **Decompression.** A source that begins with the zstd or gzip magic bytes is decompressed before it is split, whatever
65
+ its name. Concatenated frames and members are read through. Pass `decompress=False` to read the bytes as given.
66
+ - **Compressed siblings.** A path `p` reads `p.zst`, or failing that `p.gz`, when one exists. Pass
67
+ `prefer_compressed=False` to read `p` itself.
68
+ - **Laziness.** Nothing is opened until the first row is pulled.
69
+
70
+ ## Defaults worth knowing
71
+
72
+ | Option | Default | Notes |
73
+ | ----------------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
74
+ | `trim` | `True` | Strips the ECMAScript whitespace set (U+FEFF included, U+0085 not), not `str.strip`'s. CSV trims cells and headers after unquoting. |
75
+ | `skip_empty` | `True` | Drops empty records; for text, rows that trim to nothing; for JSONL, whitespace-only rows. |
76
+ | `normalize_keys` | `False` | CSV keys are the header as written. In object mode a repeated header raises `DuplicateHeaderError`. |
77
+ | `enable_quote_handling` | CSV/PSV `True`, TSV `False` | Input that ends inside quotes raises `UnterminatedQuoteError` after the rows before it. |
78
+ | `crlf` | CSV `True`, otherwise `False` | |
79
+
80
+ `drop` and `take` count the rows you receive. JSONL rejects `NaN` and `Infinity`, keeps large integers exact, and
81
+ raises `JSONRowError` with the failing row's index.
82
+
83
+ The full semantics table is in the repository's `docs/v10.md`.
84
+
85
+ ## Errors
86
+
87
+ `SpliteratorError` is the base of `UnterminatedQuoteError` (`.byte_offset`), `DuplicateHeaderError` (`.column`) and
88
+ `JSONRowError` (`.row`), each also a `ValueError`. I/O failures raise the usual `OSError` subclasses.
89
+
@@ -0,0 +1,69 @@
1
+ # spliterator (Python)
2
+
3
+ ```sh
4
+ pip install sister-software-spliterator
5
+ ```
6
+
7
+ The distribution is `sister-software-spliterator`; the import name is `spliterator`.
8
+
9
+ Streaming readers for delimited text, CSV, TSV, PSV and JSONL, with transparent zstd and gzip decompression.
10
+
11
+ This is the Python counterpart of the [`spliterator`](https://www.npmjs.com/package/spliterator) npm package and the
12
+ [`spliterator`](https://crates.io/crates/spliterator) Rust crate. All three read the same input into the same rows:
13
+ the same defaults, the same trimming, the same quote rules and the same errors. A shared conformance suite holds them
14
+ to it.
15
+
16
+ ```python
17
+ import spliterator
18
+
19
+ for row in spliterator.read_csv("people.csv"): # {"Full Name": "Ada", "Age": "36"}
20
+ ...
21
+
22
+ for value in spliterator.read_jsonl("part-0000.jsonl"): # reads part-0000.jsonl.zst when it exists
23
+ ...
24
+
25
+ for line in spliterator.read_text(b" a \n\n b\n"): # "a", "b"
26
+ ...
27
+ ```
28
+
29
+ ## Async and counts
30
+
31
+ Each reader has an async twin that reads each batch on a worker thread, so the event loop never blocks on I/O:
32
+
33
+ ```python
34
+ async for row in spliterator.aread_csv("people.csv"):
35
+ ...
36
+ ```
37
+
38
+ `count_text`, `count_csv`, `count_tsv` and `count_psv` return the number of rows the matching reader would yield,
39
+ without building them.
40
+
41
+ ## Sources
42
+
43
+ A source is a path (`str` or `os.PathLike`), bytes-like data, or a binary file object.
44
+
45
+ - **Decompression.** A source that begins with the zstd or gzip magic bytes is decompressed before it is split, whatever
46
+ its name. Concatenated frames and members are read through. Pass `decompress=False` to read the bytes as given.
47
+ - **Compressed siblings.** A path `p` reads `p.zst`, or failing that `p.gz`, when one exists. Pass
48
+ `prefer_compressed=False` to read `p` itself.
49
+ - **Laziness.** Nothing is opened until the first row is pulled.
50
+
51
+ ## Defaults worth knowing
52
+
53
+ | Option | Default | Notes |
54
+ | ----------------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
55
+ | `trim` | `True` | Strips the ECMAScript whitespace set (U+FEFF included, U+0085 not), not `str.strip`'s. CSV trims cells and headers after unquoting. |
56
+ | `skip_empty` | `True` | Drops empty records; for text, rows that trim to nothing; for JSONL, whitespace-only rows. |
57
+ | `normalize_keys` | `False` | CSV keys are the header as written. In object mode a repeated header raises `DuplicateHeaderError`. |
58
+ | `enable_quote_handling` | CSV/PSV `True`, TSV `False` | Input that ends inside quotes raises `UnterminatedQuoteError` after the rows before it. |
59
+ | `crlf` | CSV `True`, otherwise `False` | |
60
+
61
+ `drop` and `take` count the rows you receive. JSONL rejects `NaN` and `Infinity`, keeps large integers exact, and
62
+ raises `JSONRowError` with the failing row's index.
63
+
64
+ The full semantics table is in the repository's `docs/v10.md`.
65
+
66
+ ## Errors
67
+
68
+ `SpliteratorError` is the base of `UnterminatedQuoteError` (`.byte_offset`), `DuplicateHeaderError` (`.column`) and
69
+ `JSONRowError` (`.row`), each also a `ValueError`. I/O failures raise the usual `OSError` subclasses.
@@ -0,0 +1,37 @@
1
+ [package]
2
+ name = "spliterator"
3
+ description = "Streaming readers for delimited text, CSV, TSV and JSONL with transparent zstd/gzip decompression. The Rust counterpart of the spliterator npm package, sharing its semantics."
4
+ version.workspace = true
5
+ edition.workspace = true
6
+ rust-version.workspace = true
7
+ license.workspace = true
8
+ authors.workspace = true
9
+ repository.workspace = true
10
+ homepage.workspace = true
11
+ readme = "README.md"
12
+ # The conformance runner reads fixtures from the repository root, so it does not travel with the package.
13
+ include = ["src/**", "README.md", "LICENSE.md", "Cargo.toml"]
14
+ keywords = ["csv", "jsonl", "tsv", "streaming", "delimited"]
15
+ categories = ["parser-implementations", "encoding"]
16
+
17
+ [features]
18
+ default = ["zstd", "gzip", "json"]
19
+ zstd = ["dep:zstd"]
20
+ gzip = ["dep:flate2"]
21
+ json = ["dep:serde_json"]
22
+
23
+ [dependencies]
24
+ memchr = "2.7"
25
+ regex = { version = "1.10", default-features = false, features = [
26
+ "std",
27
+ "unicode-perl",
28
+ "unicode-gencat",
29
+ "unicode-case",
30
+ ] }
31
+ zstd = { version = "0.14", optional = true }
32
+ flate2 = { version = "1.0", optional = true }
33
+ serde_json = { version = "1.0", optional = true }
34
+
35
+ [dev-dependencies]
36
+ serde_json = "1.0"
37
+ base64 = "0.22"
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Teffen Ellis, Sister Software
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.
@@ -0,0 +1,43 @@
1
+ # spliterator (Rust)
2
+
3
+ Streaming readers for delimited text, CSV, TSV, PSV and JSONL, with transparent zstd and gzip decompression.
4
+
5
+ This is the Rust counterpart of the [`spliterator`](https://www.npmjs.com/package/spliterator) npm package, and the
6
+ engine behind its Python package. All three read the same input into the same rows: the same defaults, the same
7
+ trimming, the same quote rules and the same errors. A shared conformance suite holds them to it.
8
+
9
+ ```rust
10
+ use spliterator::{csv, jsonl, text};
11
+
12
+ for row in csv::Reader::open("people.csv", csv::Options::csv())? {
13
+ let row = row?;
14
+ println!("{:?}", row.get("Full Name"));
15
+ }
16
+
17
+ // Reads part-0000.jsonl.zst when it exists.
18
+ for value in jsonl::Reader::open("part-0000.jsonl", jsonl::Options::default())? {
19
+ println!("{}", value?);
20
+ }
21
+
22
+ let lines: Vec<String> = text::Reader::from_bytes(b" a \n\n b\n", text::Options::default())?.collect::<Result<_, _>>()?;
23
+ assert_eq!(lines, ["a", "b"]);
24
+
25
+ ```
26
+
27
+ `text::count` and `csv::count` return the number of rows the matching reader would yield, without building them.
28
+
29
+ ## Sources
30
+
31
+ `Reader::open` takes a path, bytes, or any `Read` (`Source`). A path `p` reads `p.zst`, or failing that `p.gz`, when one
32
+ exists; any source beginning with the zstd or gzip magic bytes is decompressed, frames and members concatenated. Both
33
+ are on by default (`OpenOptions`). `Reader::new` reads a stream as given.
34
+
35
+ ## Features
36
+
37
+ | Feature | Default | Enables |
38
+ | ------- | ------- | ------------------------------------------------------ |
39
+ | `zstd` | yes | zstd decompression (libzstd, through the `zstd` crate) |
40
+ | `gzip` | yes | gzip decompression (`flate2`, pure Rust) |
41
+ | `json` | yes | the `jsonl` module (`serde_json`) |
42
+
43
+ The full semantics table is in the repository's `docs/v10.md`.