zlight_csv 0.3.0-aarch64-linux → 0.4.0-aarch64-linux
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.
- checksums.yaml +4 -4
- data/README.md +34 -2
- data/VERSION +1 -1
- data/lib/zlight_csv/3.0/zlight_csv.so +0 -0
- data/lib/zlight_csv/3.1/zlight_csv.so +0 -0
- data/lib/zlight_csv/3.2/zlight_csv.so +0 -0
- data/lib/zlight_csv/3.3/zlight_csv.so +0 -0
- data/lib/zlight_csv.rb +65 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0b7b428705db23dd7f65a27fb21a28f3702b2b0565099e9e3dae3353328a61b8
|
|
4
|
+
data.tar.gz: 94664f11ef0d307e911693979d768ed9c97d79d09de88bacf8ee7a3731a5b36d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0a8ba87db633d2ea2bf74f0eec4c10db58d0c495b3b7a59678533e2fe01e0e7a598b42bde6d0d9769887ed8089f4dbb3190a2b95f4eb0f019edd9fc90de8282a
|
|
7
|
+
data.tar.gz: 022f03acaff20db6046cde59171e080f5e88fa7bd9e139cb2311ad4d131f1071104cfb6376a4056d1089442da058c11408cf2b958817003a79e246c03085f612
|
data/README.md
CHANGED
|
@@ -102,7 +102,7 @@ ZLight.parse (full): 73ms
|
|
|
102
102
|
ZLight.stream (lazy): 0.3ms ← 5,600x faster!
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
### Options
|
|
105
|
+
### Options (Reading)
|
|
106
106
|
|
|
107
107
|
| Option | Default | Description |
|
|
108
108
|
|--------|---------|-------------|
|
|
@@ -112,6 +112,38 @@ ZLight.stream (lazy): 0.3ms ← 5,600x faster!
|
|
|
112
112
|
| `quote_char` | `"` | Quote character |
|
|
113
113
|
| `flexible` | `true` | Allow rows with varying column counts |
|
|
114
114
|
|
|
115
|
+
### Writing CSV
|
|
116
|
+
|
|
117
|
+
Generate CSV strings or write directly to files:
|
|
118
|
+
|
|
119
|
+
```ruby
|
|
120
|
+
# Generate CSV from array of hashes
|
|
121
|
+
csv = ZLight.generate([
|
|
122
|
+
{ name: "Alice", age: 30 },
|
|
123
|
+
{ name: "Bob", age: 25 }
|
|
124
|
+
])
|
|
125
|
+
# => "name,age\nAlice,30\nBob,25\n"
|
|
126
|
+
|
|
127
|
+
# Generate from array of arrays (no headers)
|
|
128
|
+
csv = ZLight.generate([["Alice", 30], ["Bob", 25]])
|
|
129
|
+
# => "Alice,30\nBob,25\n"
|
|
130
|
+
|
|
131
|
+
# Write directly to a file
|
|
132
|
+
ZLight.write("users.csv", data)
|
|
133
|
+
|
|
134
|
+
# With options
|
|
135
|
+
ZLight.generate(data, col_sep: "\t", force_quotes: true)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Options (Writing)
|
|
139
|
+
|
|
140
|
+
| Option | Default | Description |
|
|
141
|
+
|--------|---------|-------------|
|
|
142
|
+
| `headers` | `true` | Write header row (for hash input) |
|
|
143
|
+
| `col_sep` | `","` | Column separator |
|
|
144
|
+
| `quote_char` | `"` | Quote character |
|
|
145
|
+
| `force_quotes` | `false` | Quote all fields, not just those requiring it |
|
|
146
|
+
|
|
115
147
|
## Compatibility
|
|
116
148
|
|
|
117
149
|
Works as a drop-in replacement for common `CSV.parse` patterns:
|
|
@@ -132,7 +164,7 @@ ZLight.parse(data, converters: :numeric)
|
|
|
132
164
|
## Roadmap
|
|
133
165
|
|
|
134
166
|
- [x] Streaming/lazy parsing for large files
|
|
135
|
-
- [
|
|
167
|
+
- [x] CSV writing support
|
|
136
168
|
- [ ] Custom converter procs
|
|
137
169
|
|
|
138
170
|
## Contributing
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.4.0
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/zlight_csv.rb
CHANGED
|
@@ -91,6 +91,39 @@ module ZLight
|
|
|
91
91
|
# @note The parse method is defined in the Rust native extension.
|
|
92
92
|
# See ext/zlight_csv/src/lib.rs for implementation.
|
|
93
93
|
|
|
94
|
+
# Generates a CSV string from an array of rows.
|
|
95
|
+
#
|
|
96
|
+
# This method is implemented as a native Rust extension for maximum performance.
|
|
97
|
+
#
|
|
98
|
+
# @param rows [Array<Hash>, Array<Array>] The data to convert to CSV
|
|
99
|
+
# @param headers [Boolean] Write header row for hash input (default: true)
|
|
100
|
+
# @param col_sep [String] Column separator character (default: ",")
|
|
101
|
+
# @param quote_char [String] Quote character for escaping (default: '"')
|
|
102
|
+
# @param force_quotes [Boolean] Force quoting all fields (default: false)
|
|
103
|
+
#
|
|
104
|
+
# @return [String] The generated CSV string
|
|
105
|
+
#
|
|
106
|
+
# @raise [ArgumentError] If options are invalid or rows format is mixed
|
|
107
|
+
#
|
|
108
|
+
# @example Generate CSV from array of hashes
|
|
109
|
+
# ZLight.generate([{name: "Alice", age: 30}, {name: "Bob", age: 25}])
|
|
110
|
+
# # => "name,age\nAlice,30\nBob,25\n"
|
|
111
|
+
#
|
|
112
|
+
# @example Generate CSV from array of arrays (no headers)
|
|
113
|
+
# ZLight.generate([["Alice", 30], ["Bob", 25]])
|
|
114
|
+
# # => "Alice,30\nBob,25\n"
|
|
115
|
+
#
|
|
116
|
+
# @example Generate without headers
|
|
117
|
+
# ZLight.generate([{name: "Alice"}], headers: false)
|
|
118
|
+
# # => "Alice\n"
|
|
119
|
+
#
|
|
120
|
+
# @example Generate TSV
|
|
121
|
+
# ZLight.generate([{a: 1, b: 2}], col_sep: "\t")
|
|
122
|
+
# # => "a\tb\n1\t2\n"
|
|
123
|
+
#
|
|
124
|
+
# @note The generate method is defined in the Rust native extension.
|
|
125
|
+
# See ext/zlight_csv/src/writer.rs for implementation.
|
|
126
|
+
|
|
94
127
|
# StreamReader is defined in the Rust extension.
|
|
95
128
|
# It provides lazy/streaming CSV parsing for large files.
|
|
96
129
|
#
|
|
@@ -133,6 +166,38 @@ module ZLight
|
|
|
133
166
|
parse(File.read(path, encoding: 'UTF-8'), **options)
|
|
134
167
|
end
|
|
135
168
|
|
|
169
|
+
# Writes CSV data to a file.
|
|
170
|
+
#
|
|
171
|
+
# Convenience method that generates CSV and writes to disk.
|
|
172
|
+
# The file is written with UTF-8 encoding.
|
|
173
|
+
#
|
|
174
|
+
# @param path [String] Path to the output CSV file
|
|
175
|
+
# @param rows [Array<Hash>, Array<Array>] The data to write
|
|
176
|
+
# @param headers [Boolean] Write header row for hash input (default: true)
|
|
177
|
+
# @param col_sep [String] Column separator character (default: ",")
|
|
178
|
+
# @param quote_char [String] Quote character for escaping (default: '"')
|
|
179
|
+
# @param force_quotes [Boolean] Force quoting all fields (default: false)
|
|
180
|
+
#
|
|
181
|
+
# @return [Integer] Number of bytes written
|
|
182
|
+
#
|
|
183
|
+
# @raise [Errno::ENOENT] If the directory does not exist
|
|
184
|
+
# @raise [Errno::EACCES] If the file is not writable
|
|
185
|
+
# @raise [ArgumentError] If options are invalid
|
|
186
|
+
#
|
|
187
|
+
# @example Write hashes to CSV
|
|
188
|
+
# ZLight.write("users.csv", [{name: "Alice", age: 30}])
|
|
189
|
+
#
|
|
190
|
+
# @example Write arrays to CSV
|
|
191
|
+
# ZLight.write("data.csv", [["a", "b"], [1, 2]])
|
|
192
|
+
#
|
|
193
|
+
# @example Write TSV
|
|
194
|
+
# ZLight.write("data.tsv", rows, col_sep: "\t")
|
|
195
|
+
#
|
|
196
|
+
# @see .generate
|
|
197
|
+
def write(path, rows, **options)
|
|
198
|
+
File.write(path, generate(rows, **options), encoding: 'UTF-8')
|
|
199
|
+
end
|
|
200
|
+
|
|
136
201
|
# Iterates over each row in the CSV string.
|
|
137
202
|
#
|
|
138
203
|
# When called with a block, yields each row and returns nil.
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zlight_csv
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: aarch64-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Zaidan Chaudhary
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-06-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: |
|
|
14
14
|
ZLight brings the speed of Rust to Ruby's CSV parsing. Built as a native
|