zsv 1.3.1 → 1.4.4
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/CHANGELOG.md +153 -2
- data/README.md +132 -240
- data/ext/zsv/ZSV_UPSTREAM +7 -0
- data/ext/zsv/common.h +0 -12
- data/ext/zsv/extconf.rb +70 -122
- data/ext/zsv/options.c +63 -62
- data/ext/zsv/options.h +8 -11
- data/ext/zsv/parser.c +390 -201
- data/ext/zsv/parser.h +35 -22
- data/ext/zsv/row.c +75 -28
- data/ext/zsv/row.h +15 -9
- data/ext/zsv/upstream.rb +55 -0
- data/ext/zsv/vendor/zsv/LICENSE +21 -0
- data/ext/zsv/vendor/zsv/VENDORED_FROM +2 -0
- data/ext/zsv/vendor/zsv/configure +1212 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/api.h +39 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/common.h +36 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext/sheet.h +8 -1
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext.h +6 -2
- data/ext/zsv/vendor/zsv/include/zsv/utils/appname.h +51 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/arg.h +50 -1
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/compiler.h +19 -8
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/dirs.h +2 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/file-mem.h +1 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/file.h +28 -2
- data/ext/zsv/vendor/zsv/include/zsv/utils/os.h +145 -0
- data/ext/zsv/vendor/zsv/include/zsv/utils/output.h +34 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/overwrite_writer.h +1 -1
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/prop.h +16 -4
- data/ext/zsv/vendor/zsv/include/zsv/utils/rng.h +35 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/signal.h +7 -0
- data/ext/zsv/vendor/zsv/include/zsv/utils/sql.h +13 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/string.h +25 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/writer.h +9 -1
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/zsv_export.h +1 -1
- data/ext/zsv/vendor/{zsv-1.3.0/include/zsv.h → zsv/include/zsv.h.in} +1 -3
- data/ext/zsv/vendor/zsv/src/Makefile +238 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv.c +152 -14
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv_internal.c +108 -50
- data/ext/zsv/vendor/zsv/src/zsv_scan_delim_fast.c +741 -0
- data/ext/zsv/vendor/zsv/src/zsv_scan_simd_avx2.h +89 -0
- data/ext/zsv/vendor/zsv/src/zsv_scan_simd_neon.h +80 -0
- data/ext/zsv/vendor/zsv/src/zsv_scan_simd_sse2.h +93 -0
- data/ext/zsv/vendor/zsv/src/zsv_scan_simd_wasm.h +79 -0
- data/ext/zsv/vendor/zsv/src/zsv_strencode.c +84 -0
- data/ext/zsv/zsv_ext.c +176 -105
- data/lib/zsv/errors.rb +32 -0
- data/lib/zsv/input.rb +88 -0
- data/lib/zsv/options.rb +132 -0
- data/lib/zsv/strict_validator.rb +124 -0
- data/lib/zsv/version.rb +1 -1
- data/lib/zsv.rb +137 -35
- metadata +81 -230
- data/ext/zsv/vendor/zsv-1.3.0/app/2db.c +0 -756
- data/ext/zsv/vendor/zsv-1.3.0/app/2json.c +0 -381
- data/ext/zsv/vendor/zsv-1.3.0/app/2tsv.c +0 -228
- data/ext/zsv/vendor/zsv-1.3.0/app/builtin/help.c +0 -123
- data/ext/zsv/vendor/zsv-1.3.0/app/builtin/license.c +0 -39
- data/ext/zsv/vendor/zsv-1.3.0/app/builtin/register.c +0 -104
- data/ext/zsv/vendor/zsv-1.3.0/app/builtin/thirdparty.c +0 -41
- data/ext/zsv/vendor/zsv-1.3.0/app/builtin/unregister.c +0 -1
- data/ext/zsv/vendor/zsv-1.3.0/app/builtin/version.c +0 -14
- data/ext/zsv/vendor/zsv-1.3.0/app/check/simdutf_wrapper.h +0 -19
- data/ext/zsv/vendor/zsv-1.3.0/app/check/utf8.c +0 -116
- data/ext/zsv/vendor/zsv-1.3.0/app/check.c +0 -194
- data/ext/zsv/vendor/zsv-1.3.0/app/cli.c +0 -796
- data/ext/zsv/vendor/zsv-1.3.0/app/cli_const.h +0 -41
- data/ext/zsv/vendor/zsv-1.3.0/app/cli_export.h +0 -16
- data/ext/zsv/vendor/zsv-1.3.0/app/cli_ini.c +0 -280
- data/ext/zsv/vendor/zsv-1.3.0/app/cli_internal.h +0 -36
- data/ext/zsv/vendor/zsv-1.3.0/app/compare.c +0 -913
- data/ext/zsv/vendor/zsv-1.3.0/app/compare.h +0 -23
- data/ext/zsv/vendor/zsv-1.3.0/app/compare_added_column.c +0 -20
- data/ext/zsv/vendor/zsv-1.3.0/app/compare_internal.h +0 -140
- data/ext/zsv/vendor/zsv-1.3.0/app/compare_sort.c +0 -91
- data/ext/zsv/vendor/zsv-1.3.0/app/compare_unique_colname.c +0 -81
- data/ext/zsv/vendor/zsv-1.3.0/app/count-pull.c +0 -82
- data/ext/zsv/vendor/zsv-1.3.0/app/count.c +0 -404
- data/ext/zsv/vendor/zsv-1.3.0/app/desc.c +0 -569
- data/ext/zsv/vendor/zsv-1.3.0/app/echo.c +0 -365
- data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/my_extension.c +0 -366
- data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/mysheet_extension.c +0 -341
- data/ext/zsv/vendor/zsv-1.3.0/app/ext_template/YOUR_EXTENSION_zsvext.c +0 -263
- data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.c +0 -298
- data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.h +0 -157
- data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/json_numeric.c +0 -177
- data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.c +0 -444
- data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.h +0 -145
- data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/utils.c +0 -110
- data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/include/memfile.h +0 -15
- data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/src/memfile.c +0 -64
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sglib/sglib.h +0 -1955
- data/ext/zsv/vendor/zsv-1.3.0/app/external/simdutf/simdutf.h +0 -6802
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.c +0 -230517
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.h +0 -12174
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_and_csv_vtab.c +0 -2
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.c +0 -142
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.h +0 -49
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-zsv.c +0 -485
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab.c +0 -1015
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3ext.h +0 -663
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/vtab_helper.c +0 -85
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_common.h +0 -75
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_gen.h +0 -167
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_parse.h +0 -228
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_tree.h +0 -186
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_version.h +0 -23
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_common.h +0 -76
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_gen.h +0 -167
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_parse.h +0 -238
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_tree.h +0 -186
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl.c +0 -184
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.c +0 -52
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.h +0 -34
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.c +0 -103
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.h +0 -57
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_bytestack.h +0 -69
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.c +0 -220
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.h +0 -34
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_gen.c +0 -362
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.c +0 -764
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.h +0 -117
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.c +0 -508
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.h +0 -78
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_tree.c +0 -505
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_version.c +0 -7
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/json_value.h +0 -59
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/yajl_helper.h +0 -208
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper.c +0 -795
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper_internal.h +0 -28
- data/ext/zsv/vendor/zsv-1.3.0/app/flatten.c +0 -851
- data/ext/zsv/vendor/zsv-1.3.0/app/jq.c +0 -106
- data/ext/zsv/vendor/zsv-1.3.0/app/jq.h +0 -6
- data/ext/zsv/vendor/zsv-1.3.0/app/mv.c +0 -113
- data/ext/zsv/vendor/zsv-1.3.0/app/noop.c +0 -90
- data/ext/zsv/vendor/zsv-1.3.0/app/overwrite.c +0 -295
- data/ext/zsv/vendor/zsv-1.3.0/app/paste.c +0 -175
- data/ext/zsv/vendor/zsv-1.3.0/app/pretty.c +0 -693
- data/ext/zsv/vendor/zsv-1.3.0/app/prop.c +0 -980
- data/ext/zsv/vendor/zsv-1.3.0/app/rm.c +0 -131
- data/ext/zsv/vendor/zsv-1.3.0/app/select/fixed.c +0 -130
- data/ext/zsv/vendor/zsv-1.3.0/app/select/internal.h +0 -118
- data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.c +0 -45
- data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.h +0 -41
- data/ext/zsv/vendor/zsv-1.3.0/app/select/processing.c +0 -107
- data/ext/zsv/vendor/zsv-1.3.0/app/select/rand.c +0 -20
- data/ext/zsv/vendor/zsv-1.3.0/app/select/regex.c +0 -61
- data/ext/zsv/vendor/zsv-1.3.0/app/select/search.c +0 -14
- data/ext/zsv/vendor/zsv-1.3.0/app/select/selection.c +0 -192
- data/ext/zsv/vendor/zsv-1.3.0/app/select/usage.c +0 -72
- data/ext/zsv/vendor/zsv-1.3.0/app/select-pull.c +0 -812
- data/ext/zsv/vendor/zsv-1.3.0/app/select.c +0 -753
- data/ext/zsv/vendor/zsv-1.3.0/app/serialize.c +0 -372
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/curses.h +0 -15
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/cursor.c +0 -119
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/errors.c +0 -45
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.c +0 -63
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.h +0 -12
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/filter.c +0 -166
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers.c +0 -214
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers_internal.h +0 -128
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/help.c +0 -43
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.c +0 -81
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.h +0 -25
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.c +0 -325
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.h +0 -73
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/lexer.c +0 -203
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/newline_handler.c +0 -7
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/pivot.c +0 -318
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.c +0 -134
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.h +0 -119
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/read-data.c +0 -322
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.c +0 -203
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.h +0 -36
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet-sql.c +0 -167
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet_internal.h +0 -36
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sqlfilter.c +0 -153
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/terminfo.c +0 -32
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.c +0 -312
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.h +0 -29
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/ui_buffer.c +0 -266
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/usage.c +0 -9
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/utf8-width.c +0 -60
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet.c +0 -1007
- data/ext/zsv/vendor/zsv-1.3.0/app/sql.c +0 -453
- data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.c +0 -101
- data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.h +0 -49
- data/ext/zsv/vendor/zsv-1.3.0/app/stack.c +0 -393
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/arg.c +0 -322
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/cache.c +0 -228
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/cat.c +0 -91
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.c +0 -240
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.h +0 -63
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/clock.c +0 -57
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/db.c +0 -148
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs-no-jq.c +0 -2
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs.c +0 -427
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_from_json.c +0 -253
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_to_json.c +0 -121
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/dl.c +0 -20
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/emcc/fs_api.c +0 -159
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/err.c +0 -24
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/file-mem.c +0 -180
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/file.c +0 -256
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.c +0 -197
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.h +0 -49
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/jq.c +0 -400
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/json.c +0 -120
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/mem.c +0 -18
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/memmem.c +0 -132
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/os.c +0 -178
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite.c +0 -258
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite_writer.c +0 -246
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8-test.c +0 -123
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.c +0 -153
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.h +0 -54
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/prop.c +0 -267
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/signal.c +0 -53
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/string.c +0 -357
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dir_exists_longpath.c +0 -83
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dl.c +0 -33
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/fopen_longpath.c +0 -184
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/foreach_dirent_longpath.c +0 -292
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.c +0 -259
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.h +0 -13
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/mkdir_longpath.c +0 -255
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/remove_longpath.c +0 -96
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/writer.c +0 -361
- data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command.h +0 -40
- data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command_standalone.c +0 -16
- data/ext/zsv/vendor/zsv-1.3.0/app/zsv_main.h +0 -44
- data/ext/zsv/vendor/zsv-1.3.0/examples/js/zsv_parser_api_dummy.c +0 -3
- data/ext/zsv/vendor/zsv-1.3.0/examples/lib/parse_by_chunk.c +0 -100
- data/ext/zsv/vendor/zsv-1.3.0/examples/lib/print_my_column.c +0 -143
- data/ext/zsv/vendor/zsv-1.3.0/examples/lib/pull.c +0 -89
- data/ext/zsv/vendor/zsv-1.3.0/examples/lib/simple.c +0 -123
- data/ext/zsv/vendor/zsv-1.3.0/fuzz/fuzz.c +0 -16
- data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/os.h +0 -54
- data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/sql.h +0 -11
- data/ext/zsv/vendor/zsv-1.3.0/src/zsv_strencode.c +0 -51
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext/implementation.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext/implementation_private.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/cache.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/clock.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/db.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/dl.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/emcc/fs_api.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/err.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/jq.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/json.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/mem.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/memmem.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/overwrite.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/utf8.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/win/dl.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/vector_delim.c +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv_scan_delim.c +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv_scan_fixed.c +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 80777f16398f7ec2992d76b49a67f1be772a1eb03f8219684bcaeffc2a2094ae
|
|
4
|
+
data.tar.gz: 64bb251b0db24011d8632ae7f76ae39af9200d38403f78f49f4f3200ca9c01fa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c9fa2228e696cddee3c0c9955f8012ae4095ec68f27528e0815c24998ef24589107fd6aea6433d0b6831fd149800e310750968283198ddf1b82595e7b225889c
|
|
7
|
+
data.tar.gz: 29d1ae51f114c31354c0eb318060a790ebc954da5d0b14efe54c77f240409590e03e34fa88876e13e08c4bed41855d34f34b87d0f5903c92dbf2fa185ea7a2e8
|
data/CHANGELOG.md
CHANGED
|
@@ -2,8 +2,159 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
|
-
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
6
|
+
|
|
7
|
+
Versioning: gem `X.Y.Z` ships the zsv C library `X.Y.Z` (a gem-only release
|
|
8
|
+
adds a fourth segment, `X.Y.Z.N`), so the version number follows zsv, not
|
|
9
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html). A release can
|
|
10
|
+
therefore change behaviour without a major bump: every such change is listed
|
|
11
|
+
under **Changed — breaking**, with what to do before upgrading.
|
|
12
|
+
|
|
13
|
+
## [Unreleased]
|
|
14
|
+
|
|
15
|
+
## [1.4.4] - 2026-11-23
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- IO sources: `ZSV::Parser.new(io)`, `ZSV.parse_enum(io)` read any object
|
|
19
|
+
responding to `#read` (File, StringIO, pipes, sockets) as the rows are
|
|
20
|
+
consumed. Fields carry the IO's external encoding.
|
|
21
|
+
- `ZSV.parse_line(line, **options)`, like `CSV.parse_line`.
|
|
22
|
+
- `ZSV::Parser.from_string(csv, **options)` and
|
|
23
|
+
`ZSV::Parser.from_path(path, **options)`: build a parser without the
|
|
24
|
+
String-is-data-or-path guess of `ZSV::Parser.new`.
|
|
25
|
+
- `headers:` accepts a String (the header names as one CSV line) and
|
|
26
|
+
`:first_row` (same as `true`), as in `CSV`.
|
|
27
|
+
- `ZSV.open` and `ZSV.foreach` accept a read mode: `"r"`, `"rb"`, `"rt"`, and
|
|
28
|
+
`"r:<encoding>"` (`"r:bom|utf-8"`, `"r:iso-8859-1"`). Write modes raise
|
|
29
|
+
`ArgumentError`.
|
|
30
|
+
- Strict mode: `liberal_parsing: false` validates the input like `CSV` does
|
|
31
|
+
and raises `ZSV::MalformedCSVError` (quoting errors) or
|
|
32
|
+
`ZSV::InvalidEncodingError` (bytes invalid in the source encoding), both
|
|
33
|
+
with `#line_number` (alias `#lineno`). It reads the whole input before the
|
|
34
|
+
first row and is slower than the default lenient mode.
|
|
35
|
+
- `max_row_size` (default 262144 bytes) and `max_columns` (default 1024)
|
|
36
|
+
options: the limits past which a row raises instead of being cut.
|
|
37
|
+
- Precompiled gems for x86_64 and aarch64 Linux (glibc and musl) and x86_64
|
|
38
|
+
and arm64 macOS, published with each release: no C compiler needed there.
|
|
39
|
+
- Offline install: the zsv source ships inside the gem, pinned by SHA-256
|
|
40
|
+
(see Security / Packaging). `gem install` never touches the network.
|
|
41
|
+
|
|
42
|
+
### Changed — breaking, read before upgrading
|
|
43
|
+
- **Unknown options raise `ArgumentError`** (`unknown keyword: :converters`).
|
|
44
|
+
They were silently ignored before. Upgrade: remove options ZSV does not
|
|
45
|
+
implement (`converters`, `strip`, `skip_blanks`, `nil_value`, ...; the
|
|
46
|
+
list is in `docs/API_REFERENCE.md`) and do that work on the rows.
|
|
47
|
+
- **`quote_char` other than `'"'` and `row_sep` other than `:auto`, `"\n"`,
|
|
48
|
+
`"\r\n"` or `"\r"` raise `ArgumentError`.** They were accepted and had no
|
|
49
|
+
effect. Upgrade: drop them; zsv only quotes with `"` and auto-detects the
|
|
50
|
+
three line endings.
|
|
51
|
+
- **`liberal_parsing: false` now validates**: it is slower and raises on
|
|
52
|
+
malformed quoting or invalid encoding, where it used to be ignored (rows
|
|
53
|
+
were always parsed leniently). Upgrade: omit the option, or pass
|
|
54
|
+
`liberal_parsing: true`, to keep the old lenient behaviour and speed.
|
|
55
|
+
- **Field encoding follows the source**: the String's encoding for
|
|
56
|
+
`ZSV.parse`, the IO's external encoding for IOs, `encoding:` or the mode's
|
|
57
|
+
encoding for files (UTF-8 when none is given). Fields were always tagged
|
|
58
|
+
UTF-8 before, so a binary String (`File.binread`, `"..".b`) now yields
|
|
59
|
+
BINARY (ASCII-8BIT) fields. Upgrade: `force_encoding('UTF-8')` the input,
|
|
60
|
+
or pass `encoding: 'UTF-8'`.
|
|
61
|
+
- **A blank line is an empty row `[]`, as in `CSV`**: `ZSV.parse("a\n\nb\n")`
|
|
62
|
+
is `[["a"], [], ["b"]]`, was `[["a"], [""], ["b"]]`. With headers it is a
|
|
63
|
+
Hash with every header mapped to `nil` (was `{first_header => ""}`); blank
|
|
64
|
+
lines before the header row are skipped. A line holding only `""` is now
|
|
65
|
+
`[""]` (it was dropped). Upgrade: `reject(&:empty?)` if you counted on
|
|
66
|
+
non-empty rows.
|
|
67
|
+
- **Header rows match `CSV`**: a row shorter than the headers has `nil` for
|
|
68
|
+
the missing fields (the keys were absent), and when a header name repeats
|
|
69
|
+
its first column wins (the last one did). Upgrade: `row.compact` for the
|
|
70
|
+
old missing-key shape; rename duplicate headers to read every column.
|
|
71
|
+
- **How `ZSV::Parser.new` reads its argument**: a `Pathname` or other
|
|
72
|
+
`#to_path` object that is not an open stream is a path (it was read as an
|
|
73
|
+
IO and looped forever); a String holding a line ending or a NUL byte, or
|
|
74
|
+
empty, is data; otherwise an existing file of that name is a path (a file
|
|
75
|
+
with a comma in its name is found); otherwise a String containing
|
|
76
|
+
`col_sep` is data (`"a,b"`, `"a;b"` with `col_sep: ";"`); anything else is
|
|
77
|
+
a missing path (`Errno::ENOENT`). Upgrade: use `ZSV::Parser.from_string` or
|
|
78
|
+
`from_path` (or `ZSV.parse` / `ZSV.open`) to choose explicitly.
|
|
79
|
+
- **`skip_lines` must be a non-negative Integer**; a Regexp, a String or a
|
|
80
|
+
negative number raises `ArgumentError` (a negative value was ignored).
|
|
81
|
+
Upgrade: skip matching rows yourself (`each.reject { ... }`).
|
|
82
|
+
- **Over-long and over-wide rows raise `ZSV::MalformedCSVError`** instead of
|
|
83
|
+
being returned cut short: a row longer than `max_row_size` (default
|
|
84
|
+
256 KiB, the old buffer size) and a row with more than `max_columns`
|
|
85
|
+
(default 1024) fields, whose extra fields were dropped. Upgrade: pass a
|
|
86
|
+
larger `max_row_size:` / `max_columns:` for such files.
|
|
87
|
+
- **A source build targets the baseline CPU** (SSE2 on x86_64, NEON on
|
|
88
|
+
aarch64; zsv's SIMD scanner stays on) instead of the build machine's
|
|
89
|
+
(`-march=native`, AVX2). A binary built in a Docker image on one CPU used
|
|
90
|
+
to die with SIGILL on another. Upgrade: nothing to do; to build for the
|
|
91
|
+
local CPU when the code only runs where it was built,
|
|
92
|
+
`gem install zsv --platform ruby -- --enable-native` (or `ZSV_NATIVE=1`).
|
|
93
|
+
On the bundled benchmarks the portable and native builds were within run-to-run noise of each other (x86_64, Ruby 4.0); the Benchmarks workflow reports current numbers.
|
|
94
|
+
|
|
95
|
+
### Changed
|
|
96
|
+
- Upgraded the bundled zsv C library from 1.4.3 to 1.4.4. Parser-library
|
|
97
|
+
changes are small: malformed-UTF-8 replacement now works on targets where
|
|
98
|
+
`char` is unsigned (e.g. gcc on ARM Linux), plus a new optional per-cell
|
|
99
|
+
malformed-UTF-8 handler this gem does not use yet. Most of the release is the
|
|
100
|
+
zsv CLI. See the
|
|
101
|
+
[zsv 1.4.4 release notes](https://github.com/liquidaty/zsv/releases/tag/v1.4.4).
|
|
102
|
+
|
|
103
|
+
### Fixed
|
|
104
|
+
- `ZSV.parse` could abort the whole Ruby process (`[BUG] Aborted`).
|
|
105
|
+
- A row longer than the read buffer (256 KiB by default) was returned cut
|
|
106
|
+
short and the rest of it dropped, with no error. A row of up to
|
|
107
|
+
`max_row_size` bytes now always parses completely, whatever `buffer_size`
|
|
108
|
+
is, and a longer row raises `ZSV::MalformedCSVError` with its line number
|
|
109
|
+
(`#line_number`).
|
|
110
|
+
- A row with more than 1024 fields lost the extra fields silently. It now
|
|
111
|
+
raises `ZSV::MalformedCSVError`; `max_columns` raises the limit.
|
|
112
|
+
- `ZSV::Parser#initialize` given a `Pathname` read it as an IO, and
|
|
113
|
+
`Pathname#read(n)` returns the first bytes of the file on every call, so the
|
|
114
|
+
rows repeated forever. A path-like object (`#to_path`, not an open stream) is
|
|
115
|
+
now opened as a path; a `File` is still read from its current position.
|
|
116
|
+
- `ZSV::Parser#each` and `#each_row` returned `nil` with a block; they return
|
|
117
|
+
the parser, like `CSV#each`.
|
|
118
|
+
- Calling `#initialize` again on a parser leaked the first parser's state; it
|
|
119
|
+
now raises `RuntimeError` and leaks nothing.
|
|
120
|
+
- Ruby code run from zsv's callbacks (an IO's `#read`, building rows) could
|
|
121
|
+
raise through zsv's C frames. It now runs under `rb_protect` and the
|
|
122
|
+
exception is re-raised once zsv has returned and the parser is released.
|
|
123
|
+
- The parser now supports GC compaction (its stored objects are marked
|
|
124
|
+
movable and updated), never calls into Ruby while being freed, calls
|
|
125
|
+
`zsv_finish` exactly once at end of input (never from `close` or free) and
|
|
126
|
+
checks its status, and leaks no `FILE *`, zsv parser or memory when options,
|
|
127
|
+
`#read`, the block or a second `#initialize` raise.
|
|
128
|
+
- A parser is no longer re-entered from its own callback or another thread:
|
|
129
|
+
that raises `ZSV::Error` instead of corrupting zsv's state.
|
|
130
|
+
- zsv's warnings no longer print to stderr.
|
|
131
|
+
|
|
132
|
+
### Security / Packaging
|
|
133
|
+
- `gem install` no longer downloads anything. The zsv source is vendored in the
|
|
134
|
+
gem (`ext/zsv/vendor/zsv`, with zsv's MIT `LICENSE`) and pinned by SHA-256 in
|
|
135
|
+
`ext/zsv/ZSV_UPSTREAM`. Before, `extconf.rb` fetched an unverified tarball
|
|
136
|
+
from GitHub at install time, and retried with TLS verification switched off
|
|
137
|
+
when verification failed.
|
|
138
|
+
- Precompiled platform gems are cross-built with `rake gem:native`
|
|
139
|
+
(rake-compiler-dock) for the baseline CPU of each architecture.
|
|
140
|
+
|
|
141
|
+
### Tooling
|
|
142
|
+
- `rake zsv:vendor`, `rake zsv:verify` and `rake "zsv:bump[X.Y.Z]"` manage the
|
|
143
|
+
vendored zsv. `bin/zsv-upstream-check` reports whether a newer zsv release
|
|
144
|
+
exists (exit 10 when one does).
|
|
145
|
+
|
|
146
|
+
## [1.4.3] - 2026-06-26
|
|
147
|
+
|
|
148
|
+
### Changed
|
|
149
|
+
- Upgraded the vendored zsv C library from 1.3.0 to 1.4.3, which introduces
|
|
150
|
+
zsv "fast mode" and assorted parser improvements and fixes. See the
|
|
151
|
+
[zsv 1.4.0 release notes](https://github.com/liquidaty/zsv/releases/tag/v1.4.0).
|
|
152
|
+
- Gem version bumped to 1.4.3 to stay in sync with the bundled zsv library.
|
|
153
|
+
|
|
154
|
+
### CI / Tooling
|
|
155
|
+
- CI now tests against Ruby 3.3, 3.4, and 4.0.
|
|
156
|
+
- Added a tag-driven release workflow that publishes to RubyGems via trusted
|
|
157
|
+
publishing (OIDC) and creates a GitHub Release (`rake release:tag`).
|
|
7
158
|
|
|
8
159
|
## [1.3.0] - 2025-12-08
|
|
9
160
|
|
data/README.md
CHANGED
|
@@ -1,311 +1,203 @@
|
|
|
1
|
-
#
|
|
1
|
+
# zsv
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/sebyx07/zsv-ruby/actions/workflows/ci.yml)
|
|
4
|
+
[](https://rubygems.org/gems/zsv)
|
|
5
|
+
[](https://rubygems.org/gems/zsv)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://developerz.ai)
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
A fast CSV parser for Ruby with the reading API of the `CSV` standard library. The parsing is done by [zsv](https://github.com/liquidaty/zsv), a SIMD-accelerated C library, through a native extension.
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- [Quick Start Guide](docs/QUICKSTART.md) - Get started in 5 minutes
|
|
10
|
-
- [API Reference](docs/API_REFERENCE.md) - Complete API documentation
|
|
11
|
-
- [Verification Report](docs/VERIFICATION.md) - Test results and metrics
|
|
11
|
+
```ruby
|
|
12
|
+
require 'zsv'
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
ZSV.foreach('data.csv', headers: true) do |row|
|
|
15
|
+
puts row['name']
|
|
16
|
+
end
|
|
17
|
+
```
|
|
14
18
|
|
|
15
|
-
- **
|
|
16
|
-
- **
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
- **Ruby 3.3+**: Modern Ruby support with proper encoding handling
|
|
19
|
+
- **Familiar**: `ZSV.foreach`, `ZSV.parse`, `ZSV.read`, `ZSV.open`, `ZSV::Parser#shift` / `#each`, with the option names `CSV` uses.
|
|
20
|
+
- **Streaming**: rows are produced as the input is read; a file is never loaded whole.
|
|
21
|
+
- **Checked against `CSV`**: the test suite compares rows with the standard library's for the same input and option. The [intended differences](#differences-from-csv) are few and listed.
|
|
22
|
+
- **Self-contained**: the zsv source ships inside the gem, pinned by SHA-256. Installing downloads nothing beyond the gem and needs no system library.
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
It parses; it does not write CSV. For generating CSV, converters, or `CSV::Table`, keep using `csv`.
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
## Install
|
|
24
27
|
|
|
25
28
|
```ruby
|
|
29
|
+
# Gemfile
|
|
26
30
|
gem 'zsv'
|
|
27
31
|
```
|
|
28
32
|
|
|
29
|
-
|
|
33
|
+
or `gem install zsv`.
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
gem install zsv
|
|
33
|
-
```
|
|
35
|
+
- **Precompiled gems** are published, from 1.4.4 on, for Linux (x86_64 and aarch64, glibc and musl) and macOS (x86_64 and arm64): no compiler needed. They are built for the baseline CPU of each architecture (SSE2 / NEON).
|
|
36
|
+
- **Everywhere else** the source gem compiles on install. That needs a C compiler and `make`, and nothing from the network: the zsv C source is inside the gem. A source build also targets the baseline CPU (SSE2 / NEON), so a binary built on one machine (a Docker image built in CI, for example) runs on any other machine of the same architecture. When the code runs only where it was built, you can build for that machine's CPU instead (`-march=native`):
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
```bash
|
|
39
|
+
gem install zsv --platform ruby -- --enable-native
|
|
40
|
+
# or ZSV_NATIVE=1 gem install zsv --platform ruby; with Bundler:
|
|
41
|
+
bundle config set --local build.zsv --enable-native
|
|
42
|
+
bundle config set --local force_ruby_platform true
|
|
43
|
+
```
|
|
36
44
|
|
|
37
|
-
|
|
45
|
+
Supported Rubies and platforms are the ones CI tests: see the matrix in [`.github/workflows/ci.yml`](.github/workflows/ci.yml). The Ruby floor is `required_ruby_version` in [`zsv.gemspec`](zsv.gemspec). Windows is not supported yet.
|
|
38
46
|
|
|
39
|
-
|
|
47
|
+
**Versioning.** The gem version is the version of the zsv library it wraps: gem `1.4.4` ships zsv `1.4.4`. A gem-only release adds a fourth segment (`1.4.4.1`).
|
|
40
48
|
|
|
41
|
-
|
|
42
|
-
require 'zsv'
|
|
49
|
+
## Usage
|
|
43
50
|
|
|
44
|
-
|
|
45
|
-
rows = ZSV.read("data.csv")
|
|
46
|
-
# => [["a", "b", "c"], ["1", "2", "3"]]
|
|
51
|
+
### Files
|
|
47
52
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
```ruby
|
|
54
|
+
# Stream rows; nothing is kept
|
|
55
|
+
ZSV.foreach('data.csv') { |row| p row } # row is an Array of Strings
|
|
56
|
+
|
|
57
|
+
# Without a block: an Enumerator
|
|
58
|
+
ZSV.foreach('data.csv').with_index { |row, i| ... }
|
|
59
|
+
ZSV.foreach('data.csv').lazy.select { |row| row[2] == 'paid' }.first(10)
|
|
52
60
|
|
|
53
|
-
#
|
|
54
|
-
rows = ZSV.
|
|
61
|
+
# Everything at once
|
|
62
|
+
rows = ZSV.read('data.csv') # => [["a", "b"], ["1", "2"]]
|
|
55
63
|
```
|
|
56
64
|
|
|
57
|
-
###
|
|
65
|
+
### Strings
|
|
58
66
|
|
|
59
67
|
```ruby
|
|
60
|
-
#
|
|
61
|
-
ZSV.
|
|
62
|
-
puts row["name"] # Hash access
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
# Provide custom headers
|
|
66
|
-
ZSV.foreach("data.csv", headers: ["id", "name", "email"]) do |row|
|
|
67
|
-
puts row["name"]
|
|
68
|
-
end
|
|
68
|
+
ZSV.parse("a,b\n1,2\n") # => [["a", "b"], ["1", "2"]]
|
|
69
|
+
ZSV.parse_line('a,"b,c"') # => ["a", "b,c"]
|
|
69
70
|
```
|
|
70
71
|
|
|
71
|
-
###
|
|
72
|
+
### Headers
|
|
72
73
|
|
|
73
74
|
```ruby
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
# Read rows one at a time
|
|
78
|
-
row = parser.shift
|
|
79
|
-
row = parser.shift
|
|
80
|
-
|
|
81
|
-
# Iterate all rows
|
|
82
|
-
parser.each do |row|
|
|
83
|
-
puts row
|
|
84
|
-
end
|
|
75
|
+
ZSV.parse("name,age\nAda,36\n", headers: true)
|
|
76
|
+
# => [{"name" => "Ada", "age" => "36"}]
|
|
85
77
|
|
|
86
|
-
#
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
# Clean up
|
|
90
|
-
parser.close
|
|
91
|
-
|
|
92
|
-
# Or use block form (auto-closes)
|
|
93
|
-
ZSV.open("data.csv") do |parser|
|
|
94
|
-
parser.each { |row| puts row }
|
|
95
|
-
end
|
|
78
|
+
# Supply the headers yourself (the first row is then data)
|
|
79
|
+
ZSV.foreach('data.csv', headers: %w[id name email]) { |row| row['email'] }
|
|
96
80
|
```
|
|
97
81
|
|
|
98
|
-
|
|
82
|
+
With headers each row is a plain `Hash`, not a `CSV::Row`.
|
|
99
83
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
| Option | Type | Default | Description |
|
|
103
|
-
|--------|------|---------|-------------|
|
|
104
|
-
| `headers` | Boolean/Array | `false` | Use first row as headers or provide custom headers |
|
|
105
|
-
| `col_sep` | String | `","` | Column delimiter (single character) |
|
|
106
|
-
| `quote_char` | String | `"\""` | Quote character (single character) |
|
|
107
|
-
| `skip_lines` | Integer | `0` | Number of lines to skip at start |
|
|
108
|
-
| `encoding` | Encoding | `UTF-8` | Source encoding |
|
|
109
|
-
| `liberal_parsing` | Boolean | `false` | Handle malformed CSV gracefully |
|
|
110
|
-
| `buffer_size` | Integer | `262144` | Buffer size in bytes (256KB default) |
|
|
84
|
+
### A parser object
|
|
111
85
|
|
|
112
86
|
```ruby
|
|
113
|
-
#
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
#
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
# Skip header comment lines
|
|
120
|
-
ZSV.foreach("data.csv", skip_lines: 2) { |row| puts row }
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
## ⚡ Performance
|
|
124
|
-
|
|
125
|
-
Benchmarks comparing ZSV vs Ruby CSV stdlib (Ruby 3.4.7):
|
|
87
|
+
ZSV.open('data.csv', headers: true) do |csv| # closed when the block returns
|
|
88
|
+
first = csv.shift # one row, or nil at the end
|
|
89
|
+
csv.headers # => ["name", "age"] (nil until the first row is read)
|
|
90
|
+
csv.each { |row| ... } # the rest
|
|
91
|
+
csv.rewind
|
|
92
|
+
end
|
|
126
93
|
|
|
94
|
+
parser = ZSV::Parser.new(io) # any object with #read; or a path, a Pathname, CSV data
|
|
95
|
+
parser.each_slice(1_000) { |batch| ... } # Enumerable
|
|
96
|
+
parser.close
|
|
127
97
|
```
|
|
128
|
-
=== Small file (1K rows, 5 cols) ===
|
|
129
|
-
CSV (stdlib): 163.4 i/s
|
|
130
|
-
ZSV: 1,013.7 i/s - 6.20x faster
|
|
131
98
|
|
|
132
|
-
|
|
133
|
-
CSV (stdlib): 10.3 i/s
|
|
134
|
-
ZSV: 54.5 i/s - 5.27x faster
|
|
99
|
+
`ZSV::Parser.new` guesses whether a String is CSV data or a path (see the [API reference](docs/API_REFERENCE.md)); `ZSV::Parser.from_string` and `ZSV::Parser.from_path` do not guess.
|
|
135
100
|
|
|
136
|
-
|
|
137
|
-
CSV (stdlib): 1.1 i/s
|
|
138
|
-
ZSV: 5.3 i/s - 5.00x faster
|
|
101
|
+
### Options
|
|
139
102
|
|
|
140
|
-
|
|
141
|
-
CSV (stdlib): 7.8 i/s
|
|
142
|
-
ZSV: 33.8 i/s - 4.33x faster
|
|
143
|
-
```
|
|
103
|
+
The common ones; the complete list, with defaults and every accepted value, is in [`docs/API_REFERENCE.md`](docs/API_REFERENCE.md).
|
|
144
104
|
|
|
145
|
-
|
|
105
|
+
| Option | Meaning |
|
|
106
|
+
|---|---|
|
|
107
|
+
| `headers` | `true`: the first row names the fields. An `Array` or a CSV line: your own names |
|
|
108
|
+
| `col_sep` | Column separator, one ASCII character (`"\t"`, `";"`, `"|"`) |
|
|
109
|
+
| `skip_lines` | Number of leading rows to drop |
|
|
110
|
+
| `liberal_parsing` | `false`: raise `ZSV::MalformedCSVError` on malformed input, as `CSV` does by default |
|
|
111
|
+
| `encoding` | Encoding the returned Strings are labelled with (no transcoding) |
|
|
146
112
|
|
|
147
|
-
```
|
|
148
|
-
|
|
113
|
+
```ruby
|
|
114
|
+
ZSV.foreach('data.tsv', col_sep: "\t", headers: true) { |row| ... }
|
|
149
115
|
```
|
|
150
116
|
|
|
151
|
-
|
|
117
|
+
An option the gem does not implement raises `ArgumentError`; nothing is silently ignored.
|
|
152
118
|
|
|
153
|
-
###
|
|
119
|
+
### Errors
|
|
154
120
|
|
|
155
|
-
|
|
121
|
+
`ZSV::Error` is the base class. `ZSV::MalformedCSVError` and `ZSV::InvalidEncodingError` mirror `CSV`'s. A missing file raises the usual `Errno::ENOENT`.
|
|
156
122
|
|
|
157
|
-
|
|
123
|
+
## Differences from `CSV`
|
|
158
124
|
|
|
159
|
-
|
|
125
|
+
The suite compares ZSV's rows with `CSV`'s for the same input. These differences are intended:
|
|
160
126
|
|
|
161
|
-
|
|
127
|
+
| | `CSV` | `ZSV` |
|
|
128
|
+
|---|---|---|
|
|
129
|
+
| Malformed input | raises by default (`liberal_parsing: false`) | **lenient by default**: zsv never rejects input. Pass `liberal_parsing: false` to validate like `CSV` and raise `ZSV::MalformedCSVError` |
|
|
130
|
+
| Empty unquoted field (`a,,b`) | `nil` | `""` |
|
|
131
|
+
| Row with headers | `CSV::Row`; `CSV.parse` returns a `CSV::Table` | a plain `Hash`; `ZSV.parse` returns an `Array` of them. With duplicate header names the first one wins, as in `CSV::Row#to_h` |
|
|
132
|
+
| Field Strings | mutable | frozen |
|
|
133
|
+
| UTF-8 BOM | kept unless `encoding: 'bom|utf-8'` | always stripped |
|
|
134
|
+
| `col_sep` | any String | one ASCII character |
|
|
135
|
+
| `quote_char` | any character | only `"` |
|
|
136
|
+
| `row_sep` | any String | always auto-detected (`\n`, `\r\n`, `\r`) |
|
|
137
|
+
| `skip_lines` | a pattern matching lines to skip | a number of leading rows to drop |
|
|
138
|
+
| `encoding` | can transcode (`'iso-8859-1:utf-8'`) | labels the returned Strings; no transcoding |
|
|
139
|
+
| Very wide rows | no limit | more than `max_columns` fields (1024 unless raised) raises `ZSV::MalformedCSVError` rather than dropping data |
|
|
140
|
+
| Very long rows | no limit | a row over `max_row_size` bytes (256 KiB unless raised) raises `ZSV::MalformedCSVError` rather than being cut short |
|
|
141
|
+
| Converters, `CSV::Table`, writing | yes | no: unsupported options raise `ArgumentError` |
|
|
162
142
|
|
|
163
|
-
|
|
143
|
+
[`docs/API_REFERENCE.md`](docs/API_REFERENCE.md) is the authoritative list.
|
|
164
144
|
|
|
165
|
-
|
|
145
|
+
## Performance
|
|
166
146
|
|
|
167
|
-
|
|
147
|
+
zsv scans input with SIMD instructions and the extension builds Ruby rows directly in C, so parsing is faster than the pure-Ruby `CSV`. How much depends on the shape of the data (row width, quoting), the options (rows as Hashes cost more than rows as Arrays), the CPU and the Ruby version, so this README does not carry a headline number.
|
|
168
148
|
|
|
169
|
-
|
|
149
|
+
**Current numbers are produced by CI**: the [Benchmarks workflow](https://github.com/sebyx07/zsv-ruby/actions/workflows/benchmark.yml) runs on every push to `main`, on x86_64 and arm64 Linux, and prints the full output in each run's summary, with the Ruby version and commit.
|
|
170
150
|
|
|
171
|
-
|
|
151
|
+
As a guide, across the maintainers' runs of `bundle exec rake bench` on x86_64 Linux, `ZSV.foreach` has typically been 3 to 4 times faster than `CSV.foreach`: a little over 2x on very wide rows, up to about 11 to 12x on heavily quoted data. `liberal_parsing: false` adds a validation pass in Ruby and lands near 2x. ZSV makes about half the allocations and holds a parsed file in noticeably less memory. These are ranges from a few machines, not a promise: the CI summaries and your own run are the reference.
|
|
172
152
|
|
|
173
|
-
|
|
153
|
+
Reproduce it on your own data and hardware:
|
|
174
154
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
#### `#each { |row| } -> self`
|
|
182
|
-
|
|
183
|
-
Iterate over all rows. Returns Enumerator without block.
|
|
184
|
-
|
|
185
|
-
#### `#rewind -> nil`
|
|
186
|
-
|
|
187
|
-
Reset parser to the beginning (file-based parsers only).
|
|
188
|
-
|
|
189
|
-
#### `#close -> nil`
|
|
190
|
-
|
|
191
|
-
Close parser and release resources.
|
|
192
|
-
|
|
193
|
-
#### `#headers -> Array|nil`
|
|
194
|
-
|
|
195
|
-
Return headers if header mode is enabled.
|
|
196
|
-
|
|
197
|
-
#### `#closed? -> Boolean`
|
|
198
|
-
|
|
199
|
-
Check if parser is closed.
|
|
200
|
-
|
|
201
|
-
#### `#read -> Array`
|
|
202
|
-
|
|
203
|
-
Read all remaining rows into an array.
|
|
204
|
-
|
|
205
|
-
### Exception Classes
|
|
206
|
-
|
|
207
|
-
- `ZSV::Error` - Base exception class
|
|
208
|
-
- `ZSV::MalformedCSVError` - Raised on CSV parsing errors
|
|
209
|
-
- `ZSV::InvalidEncodingError` - Raised on encoding issues
|
|
210
|
-
|
|
211
|
-
## Architecture
|
|
212
|
-
|
|
213
|
-
The gem follows SOLID principles with clear separation of concerns:
|
|
214
|
-
|
|
215
|
-
```
|
|
216
|
-
ext/zsv/
|
|
217
|
-
├── zsv_ext.c # Main extension entry point, Ruby API
|
|
218
|
-
├── parser.c/h # Parser state management and zsv wrapper
|
|
219
|
-
├── row.c/h # Row building and conversion (arrays/hashes)
|
|
220
|
-
├── options.c/h # Option parsing and validation
|
|
221
|
-
└── common.h # Shared types and macros
|
|
155
|
+
```bash
|
|
156
|
+
git clone https://github.com/sebyx07/zsv-ruby && cd zsv-ruby
|
|
157
|
+
bin/setup
|
|
158
|
+
bundle exec rake bench # benchmark/parse_bench.rb and benchmark/memory_bench.rb
|
|
159
|
+
BENCH_TIME=10 BENCH_JSON=parse.json bundle exec ruby benchmark/parse_bench.rb # longer runs, JSON in benchmark/results/
|
|
222
160
|
```
|
|
223
161
|
|
|
224
|
-
|
|
162
|
+
Both sides of every comparison do the same work on the same generated, fixed-seed input, and the scripts abort if the two parsers disagree on the rows.
|
|
225
163
|
|
|
226
|
-
|
|
227
|
-
2. **Streaming First**: Never load entire files into memory
|
|
228
|
-
3. **Zero-Copy Where Possible**: Minimize data copying
|
|
229
|
-
4. **Proper Resource Management**: RAII-style cleanup with Ruby GC
|
|
164
|
+
## Documentation
|
|
230
165
|
|
|
231
|
-
|
|
166
|
+
- [Quick start](docs/QUICKSTART.md)
|
|
167
|
+
- [API reference](docs/API_REFERENCE.md): every method, option, error and difference from `CSV`
|
|
168
|
+
- [`llms.txt`](llms.txt): the same reference condensed into one file for AI coding agents
|
|
169
|
+
- [Changelog](CHANGELOG.md)
|
|
232
170
|
|
|
233
|
-
|
|
234
|
-
# Clone and setup
|
|
235
|
-
git clone https://github.com/sebyx07/zsv-ruby.git
|
|
236
|
-
cd zsv-ruby
|
|
237
|
-
bundle install
|
|
171
|
+
## AI agents
|
|
238
172
|
|
|
239
|
-
|
|
240
|
-
bundle exec rake compile
|
|
173
|
+
**This project is maintained by [developerz.ai](https://developerz.ai).** Its maintainer agent triages issues, reviews every pull request, merges every pull request once its author marks it ready and CI passes, watches project health daily, follows new releases of the zsv C library, and opens release PRs. The policy is in [`.dz/maintainer/maintainer.yml`](.dz/maintainer/maintainer.yml). Breaking changes stay with the owner.
|
|
241
174
|
|
|
242
|
-
|
|
243
|
-
|
|
175
|
+
- **Using zsv in your app?** Point your agent at [`llms.txt`](llms.txt), the complete reference in one file (methods, options, differences from `CSV`, pitfalls). Paste this into your app's `CLAUDE.md` / `AGENTS.md`:
|
|
176
|
+
```markdown
|
|
177
|
+
## CSV parsing
|
|
178
|
+
CSV files are read with the zsv gem (`ZSV.foreach`, `ZSV.parse`), not Ruby's CSV. Before editing that code read
|
|
179
|
+
https://github.com/sebyx07/zsv-ruby/blob/main/llms.txt
|
|
180
|
+
```
|
|
181
|
+
- **Working on this repo?** [`CLAUDE.md`](CLAUDE.md) is the agent-instructions file (`AGENTS.md` is a symlink to it): invariants, commands, code map, how to verify a change, the release lane. [`ext/CLAUDE.md`](ext/CLAUDE.md) holds the rules for the C extension.
|
|
182
|
+
- **Claude Code**: commands in `.claude/commands/` (`/planx`, `/feature`, `/release`), skills in `.claude/skills/` (`verify-change`, `upgrade-zsv`, `debug-gc`), and a read-only reviewer subagent in `.claude/agents/` (`c-safety-reviewer`).
|
|
183
|
+
- **How the gem follows zsv**: once a month an agent runs `bin/zsv-upstream-check`; when zsv has a new release it reads the upstream changes, re-vendors the source, runs the suite, the sanitizers and the benchmarks before and after, and opens `chore: zsv X.Y.Z`. The next weekly release check then publishes gem `X.Y.Z`. The brief is [`.dz/schedules/upstream-zsv.md`](.dz/schedules/upstream-zsv.md).
|
|
244
184
|
|
|
245
|
-
|
|
246
|
-
bundle exec rake bench
|
|
247
|
-
|
|
248
|
-
# Clean build artifacts
|
|
249
|
-
bundle exec rake clean
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
### Running Tests
|
|
185
|
+
## Development
|
|
253
186
|
|
|
254
187
|
```bash
|
|
255
|
-
|
|
188
|
+
bin/setup # Ruby, gems, compile the extension (offline after the gems)
|
|
189
|
+
bin/check # the gate CI runs: repo guards, RuboCop, clang-format, compile, RSpec
|
|
190
|
+
bin/check fast # inner loop
|
|
191
|
+
bin/check asan # the suite under AddressSanitizer + UBSan (Linux)
|
|
192
|
+
bin/console # IRB with ZSV and CSV loaded
|
|
256
193
|
```
|
|
257
194
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
- Basic parsing tests
|
|
261
|
-
- Header mode tests
|
|
262
|
-
- Custom delimiter tests
|
|
263
|
-
- Error handling tests
|
|
264
|
-
- Memory leak detection
|
|
265
|
-
- API compatibility tests
|
|
266
|
-
|
|
267
|
-
## Compatibility
|
|
268
|
-
|
|
269
|
-
- **Ruby**: 3.3+ required
|
|
270
|
-
- **Platforms**: Linux, macOS (ARM and x86)
|
|
271
|
-
- **ZSV**: Compiles against zsv 1.3.0
|
|
272
|
-
|
|
273
|
-
## 🤝 Contributing
|
|
274
|
-
|
|
275
|
-
1. Fork the repository
|
|
276
|
-
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
277
|
-
3. Write tests for your changes
|
|
278
|
-
4. Ensure tests pass (`bundle exec rake spec`)
|
|
279
|
-
5. Commit your changes (`git commit -am 'Add amazing feature'`)
|
|
280
|
-
6. Push to the branch (`git push origin feature/amazing-feature`)
|
|
281
|
-
7. Open a Pull Request
|
|
282
|
-
|
|
283
|
-
## License
|
|
284
|
-
|
|
285
|
-
MIT License - see LICENSE file for details.
|
|
286
|
-
|
|
287
|
-
## 🙏 Credits
|
|
288
|
-
|
|
289
|
-
- Built on [zsv](https://github.com/liquidaty/zsv) by liquidaty
|
|
290
|
-
- Inspired by Ruby's CSV stdlib
|
|
291
|
-
- SIMD optimizations courtesy of zsv's excellent engineering
|
|
292
|
-
- Developed with [Claude Code](https://claude.com/claude-code)
|
|
293
|
-
|
|
294
|
-
## 🗺️ Roadmap
|
|
195
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). Security reports go through [SECURITY.md](SECURITY.md) (GitHub private vulnerability reporting), never a public issue. Releases are cut by merging a version bump: [RELEASE.md](RELEASE.md).
|
|
295
196
|
|
|
296
|
-
|
|
297
|
-
- [x] Basic parsing (foreach, parse, read)
|
|
298
|
-
- [x] Header mode
|
|
299
|
-
- [x] Custom delimiters
|
|
300
|
-
- [x] File and string input
|
|
197
|
+
## License and credits
|
|
301
198
|
|
|
302
|
-
|
|
303
|
-
- [ ] Type converters (`:numeric`, `:date`, `:date_time`)
|
|
304
|
-
- [ ] Header converters (`:downcase`, `:symbol`)
|
|
305
|
-
- [ ] `unconverted_fields` option
|
|
199
|
+
MIT, see [LICENSE](LICENSE). The bundled [zsv](https://github.com/liquidaty/zsv) library is by Liquidaty and also MIT-licensed; its license ships with the gem at `ext/zsv/vendor/zsv/LICENSE`.
|
|
306
200
|
|
|
307
|
-
##
|
|
201
|
+
## Star history
|
|
308
202
|
|
|
309
|
-
|
|
310
|
-
- **Discussions**: [GitHub Discussions](https://github.com/sebyx07/zsv-ruby/discussions)
|
|
311
|
-
- **Upstream zsv**: [zsv repository](https://github.com/liquidaty/zsv)
|
|
203
|
+
[](https://star-history.com/#sebyx07/zsv-ruby&Date)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# The zsv C library release this gem is built from (gem X.Y.Z wraps zsv X.Y.Z).
|
|
2
|
+
# Read by ext/zsv/upstream.rb (Rakefile, extconf.rb) and bin/zsv-upstream-check.
|
|
3
|
+
#
|
|
4
|
+
# To upgrade: `bundle exec rake "zsv:bump[NEW_VERSION]"`, which rewrites this
|
|
5
|
+
# file with the new tarball's SHA-256 and re-vendors ext/zsv/vendor/zsv.
|
|
6
|
+
version=1.4.4
|
|
7
|
+
sha256=99486b6901d6b576bf15afceb0bcc888ceeb3f555a6d489547eefe67eff52079
|
data/ext/zsv/common.h
CHANGED
|
@@ -14,21 +14,9 @@ extern VALUE eZSVError;
|
|
|
14
14
|
extern VALUE eMalformedCSVError;
|
|
15
15
|
extern VALUE eInvalidEncodingError;
|
|
16
16
|
|
|
17
|
-
/* Error handling macros */
|
|
18
|
-
#define RAISE_ZSV_ERROR(msg) rb_raise(eZSVError, "%s", (msg))
|
|
19
|
-
#define RAISE_MALFORMED_CSV(msg) rb_raise(eMalformedCSVError, "%s", (msg))
|
|
20
|
-
#define RAISE_INVALID_ENCODING(msg) rb_raise(eInvalidEncodingError, "%s", (msg))
|
|
21
|
-
|
|
22
17
|
/* Memory management macros - use Ruby's built-in */
|
|
23
18
|
#define ZSV_ALLOC(type) RB_ALLOC(type)
|
|
24
19
|
#define ZSV_ALLOC_N(type, n) RB_ALLOC_N(type, n)
|
|
25
20
|
#define ZSV_REALLOC_N(var, type, n) RB_REALLOC_N(var, type, n)
|
|
26
21
|
|
|
27
|
-
/* Debug logging (disabled in production) */
|
|
28
|
-
#ifdef DEBUG
|
|
29
|
-
#define LOG_DEBUG(fmt, ...) fprintf(stderr, "[ZSV DEBUG] " fmt "\n", ##__VA_ARGS__)
|
|
30
|
-
#else
|
|
31
|
-
#define LOG_DEBUG(fmt, ...) ((void)0)
|
|
32
|
-
#endif
|
|
33
|
-
|
|
34
22
|
#endif /* ZSV_RUBY_COMMON_H */
|