Skip to content

Instantly share code, notes, and snippets.

@minkymorgan
Forked from drjerry/tab2json.awk
Last active August 29, 2015 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minkymorgan/541d8d176e8bff347790 to your computer and use it in GitHub Desktop.
Save minkymorgan/541d8d176e8bff347790 to your computer and use it in GitHub Desktop.
NR == 1 {sep=""}
NR > 2 {sep=","}
{
if (NR == 1) {
split($0, tags);
if (EC == "") EC = "\"";
}
else {
split($0, vals);
jrec = sep"{";
for (i = 1; i <= NF; ++i) {
if (vals[i] ~ /[^0-9.]/)
jrec = jrec EC tags[i] EC ":" EC vals[i] EC;
else
jrec = jrec EC tags[i] EC ":" vals[i];
if (i < NF)
jrec = jrec ", ";
else
jrec = jrec "}";
}
print jrec;
}
}
@drjerry
Copy link

drjerry commented Oct 21, 2014

Nice fix from the original.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment