Go to file
Kailash Nadh d01ddd8a95
Merge pull request #4 from nitinprakash96/nitin/zig-0.11
Updgrade to zig 0.11.0
2023-09-06 13:00:38 +05:30
lib Updgrade to zig 0.11.0 2023-09-06 09:52:43 +05:30
src Updgrade to zig 0.11.0 2023-09-06 09:52:43 +05:30
.gitignore Support zig v0.10 and upgrade zig-clap 2023-08-02 16:00:41 +05:30
.gitmodules Add README. 2021-10-23 19:41:46 +05:30
.goreleaser.yml Add goreleaser build files. 2021-10-23 20:56:19 +05:30
LICENSE Add project files. 2021-10-23 20:55:24 +05:30
README.md Updgrade to zig 0.11.0 2023-09-06 09:52:43 +05:30
build.sh Add goreleaser build files. 2021-10-23 20:56:19 +05:30
build.zig Updgrade to zig 0.11.0 2023-09-06 09:52:43 +05:30
dummy.go Add goreleaser build files. 2021-10-23 20:56:19 +05:30

README.md

csv2json

csv2json is a fast utility that converts CSV files into JSON line files.

This is my first "hello, world" Zig learning exercise. The program may be buggy and/or faulty. Use with caution.

Usage

# Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz.
#
# 92 MB CSV file with 1 million rows. Sample:
# instrument_token,exchange_token,tradingsymbol,isin,name,last_price,expiry,strike,tick_size,lot_size,instrument_type,segment,exchange
# 272376070,1063969,"EURINR21DECFUT","","EURINR",0,"2021-12-29",0,0.0025,1,"FUT","BCD-FUT","BCD"
# ...

$ ./csv2json -i /tmp/1mil.csv > /tmp/1mil.json
Reading /tmp/1mil.csv ...
Processed 1000000 lines in 884.61 milliseconds (1000000.00 lines / second)

$ head -n /tmp/1mil.json
{"instrument_token": 272376070, "exchange_token": 1063969, "tradingsymbol": "EURINR21DECFUT", "isin": null, "name": "EURINR", "last_price": 0, "expiry": "2021-12-29", "strike": 0, "tick_size": "0.0025", "lot_size": 1, "instrument_type": "FUT", "segment": "BCD-FUT", "exchange": "BCD"}
{"instrument_token": 272086278, "exchange_token": 1062837, "tradingsymbol": "EURINR21NOVFUT", "isin": null, "name": "EURINR", "last_price": 0, "expiry": "2021-11-26", "strike": 0, "tick_size": "0.0025", "lot_size": 1, "instrument_type": "FUT", "segment": "BCD-FUT", "exchange": "BCD"}

Download

Download the latest release from the releases page.

Or, to compile with Zig (tested with v0.11.0):

  • git clone --recursive git@github.com:knadh/csv2json.git
  • cd csv2json && zig build
  • The binary will be in zig-out/bin

Licensed under the MIT license.