fastcsv-python 0.1.0__cp310-cp310-macosx_11_0_arm64.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.
- fastcsv/__init__.py +42 -0
- fastcsv/fastcsv.cpython-310-darwin.so +0 -0
- fastcsv_python-0.1.0.dist-info/METADATA +95 -0
- fastcsv_python-0.1.0.dist-info/RECORD +7 -0
- fastcsv_python-0.1.0.dist-info/WHEEL +5 -0
- fastcsv_python-0.1.0.dist-info/licenses/LICENSE +21 -0
- fastcsv_python-0.1.0.dist-info/top_level.txt +1 -0
fastcsv/__init__.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
try:
|
|
2
|
+
import pyarrow as pa
|
|
3
|
+
_HAS_ARROW = True
|
|
4
|
+
except ImportError:
|
|
5
|
+
_HAS_ARROW = False
|
|
6
|
+
|
|
7
|
+
from .fastcsv import read_csv as _read_csv_c, reader
|
|
8
|
+
|
|
9
|
+
__version__ = "0.1.0"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def read_csv(path, delimiter=",", has_header=True, error_mode="strict", raw=False):
|
|
13
|
+
"""Read an entire CSV file into a dict of numpy arrays.
|
|
14
|
+
|
|
15
|
+
When pyarrow is available, string columns are returned as
|
|
16
|
+
pyarrow.LargeStringArray (zero-copy, lazy string creation).
|
|
17
|
+
Otherwise they are returned as numpy object arrays of Python str.
|
|
18
|
+
"""
|
|
19
|
+
use_arrow = _HAS_ARROW and not raw
|
|
20
|
+
result = _read_csv_c(
|
|
21
|
+
path,
|
|
22
|
+
delimiter=delimiter,
|
|
23
|
+
has_header=has_header,
|
|
24
|
+
error_mode=error_mode,
|
|
25
|
+
_arrow_strings=use_arrow,
|
|
26
|
+
raw=raw
|
|
27
|
+
)
|
|
28
|
+
if use_arrow:
|
|
29
|
+
for key in list(result.keys()):
|
|
30
|
+
val = result[key]
|
|
31
|
+
if isinstance(val, tuple) and len(val) == 2:
|
|
32
|
+
offsets, data = val
|
|
33
|
+
buf_offsets = pa.py_buffer(offsets)
|
|
34
|
+
buf_data = pa.py_buffer(data)
|
|
35
|
+
n = len(offsets) - 1
|
|
36
|
+
result[key] = pa.LargeStringArray.from_buffers(
|
|
37
|
+
n, buf_offsets, buf_data
|
|
38
|
+
)
|
|
39
|
+
return result
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
__all__ = ["read_csv", "reader", "__version__"]
|
|
Binary file
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fastcsv-python
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Fast CSV parsing for Python via C + SIMD
|
|
5
|
+
Classifier: Programming Language :: Python :: 3
|
|
6
|
+
Classifier: Programming Language :: C
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
9
|
+
Classifier: Operating System :: MacOS
|
|
10
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: numpy>=1.20
|
|
15
|
+
Provides-Extra: bench
|
|
16
|
+
Requires-Dist: pandas; extra == "bench"
|
|
17
|
+
Requires-Dist: polars; extra == "bench"
|
|
18
|
+
Requires-Dist: pyarrow; extra == "bench"
|
|
19
|
+
Provides-Extra: arrow
|
|
20
|
+
Requires-Dist: pyarrow>=10.0; extra == "arrow"
|
|
21
|
+
Dynamic: classifier
|
|
22
|
+
Dynamic: description
|
|
23
|
+
Dynamic: description-content-type
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
Dynamic: provides-extra
|
|
26
|
+
Dynamic: requires-dist
|
|
27
|
+
Dynamic: requires-python
|
|
28
|
+
Dynamic: summary
|
|
29
|
+
|
|
30
|
+
# fastCSV
|
|
31
|
+
|
|
32
|
+
The fastest CSV parser for Python. Written in C with AVX2 SIMD acceleration,
|
|
33
|
+
memory-mapped I/O, and zero-copy columnar NumPy output.
|
|
34
|
+
|
|
35
|
+
## Benchmarks
|
|
36
|
+
|
|
37
|
+
| File | fastcsv | pandas | polars |
|
|
38
|
+
|------------------|----------|----------|----------|
|
|
39
|
+
| 1M rows mixed | 0.053s | 1.086s | 0.034s |
|
|
40
|
+
| 100k rows wide | 0.027s | 0.380s | 0.033s |
|
|
41
|
+
| 500k rows str | 0.020s | 0.935s | 0.015s |
|
|
42
|
+
|
|
43
|
+
Hardware: AMD Ryzen 5 7235HS
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
pip install fastcsv-python
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import fastcsv
|
|
53
|
+
|
|
54
|
+
# Returns dict of column_name -> numpy.ndarray
|
|
55
|
+
result = fastcsv.read_csv("data.csv")
|
|
56
|
+
result = fastcsv.read_csv("data.csv", delimiter=",", has_header=True, error_mode="strict")
|
|
57
|
+
|
|
58
|
+
# Streaming — constant memory regardless of file size
|
|
59
|
+
for chunk in fastcsv.reader("data.csv", chunk_size=10_000):
|
|
60
|
+
process(chunk)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Options
|
|
64
|
+
|
|
65
|
+
| Parameter | Default | Description |
|
|
66
|
+
|-----------|---------|-------------|
|
|
67
|
+
| `delimiter` | `","` | Field separator. Any single character. |
|
|
68
|
+
| `has_header` | `True` | Treat first row as column names. |
|
|
69
|
+
| `error_mode` | `"strict"` | `"strict"` / `"skip"` / `"replace"` |
|
|
70
|
+
| `chunk_size` | `10000` | Rows per chunk for `reader()`. |
|
|
71
|
+
|
|
72
|
+
## How it's fast
|
|
73
|
+
|
|
74
|
+
- **mmap I/O** — the OS pages in only what is needed. No `read()` syscalls.
|
|
75
|
+
- **AVX2 SIMD** — scans 32 bytes per cycle to find delimiters. Falls back to SSE4.2 (16 bytes) or scalar automatically.
|
|
76
|
+
- **Zero-copy output** — int and float columns are handed to NumPy directly from the C buffer. No data is copied.
|
|
77
|
+
- **Single-pass type inference** — column types resolved in one pass, never re-scanned.
|
|
78
|
+
- **GIL released** — the entire parse phase runs without the GIL. Safe for multi-threaded use.
|
|
79
|
+
|
|
80
|
+
## Error recovery
|
|
81
|
+
|
|
82
|
+
- `strict` — raises `ValueError` on any RFC 4180 violation.
|
|
83
|
+
- `skip` — silently drops malformed rows.
|
|
84
|
+
- `replace` — replaces malformed fields with empty string.
|
|
85
|
+
|
|
86
|
+
## Building from source
|
|
87
|
+
|
|
88
|
+
pip install numpy
|
|
89
|
+
pip install -e .
|
|
90
|
+
make test-all
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
MIT
|
|
95
|
+
904c2c43-028b-4195-83f8-cd7f0dcb5d2b
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
fastcsv_python-0.1.0.dist-info/RECORD,,
|
|
2
|
+
fastcsv_python-0.1.0.dist-info/WHEEL,sha256=8Nhm_Bhj6zIOnxtZ0ja8_oB_jIeEgkSbWA4T0_GOazU,109
|
|
3
|
+
fastcsv_python-0.1.0.dist-info/top_level.txt,sha256=C_CmMy1rzQ2nc_aCmtO8vr1mTj7-J0FZc20ymld43-k,8
|
|
4
|
+
fastcsv_python-0.1.0.dist-info/METADATA,sha256=X-RL_IN8uKd9GdkPwVTNkS98kKAiL1WC-FsmXTzMAU0,2949
|
|
5
|
+
fastcsv_python-0.1.0.dist-info/licenses/LICENSE,sha256=ESYyLizI0WWtxMeS7rGVcX3ivMezm-HOd5WdeOh-9oU,1056
|
|
6
|
+
fastcsv/fastcsv.cpython-310-darwin.so,sha256=0O1EXn6RuARmwl7oOEXP3owN9MKgXpm6ccROIE1TPw8,75008
|
|
7
|
+
fastcsv/__init__.py,sha256=DUeewj63AsqPtIRIkJayAH10ugquYu_3kyhiRYY0lKU,1260
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
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 @@
|
|
|
1
|
+
fastcsv
|