Skip to content

Instantly share code, notes, and snippets.

@hden
Created November 22, 2012 00:38
Show Gist options
  • Select an option

  • Save hden/4128725 to your computer and use it in GitHub Desktop.

Select an option

Save hden/4128725 to your computer and use it in GitHub Desktop.
Parse csv to tabular file. Usage: $ coffee csv2tab.coffee inputFile > outputFile
csv = require("ya-csv")
util = require("util")
file = "input.txt"
file ?= process.argv[2]
reader = csv.createCsvFileReader file,
separator: ","
quote : "\""
escape : "\""
comment : ""
reader.addListener "data", (data) ->
for col in data
col ?= " "
if _i is _len - 1
util.puts col
else
util.print col + "\t"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment