#!/bin/sh # Quote everything, tr , "\t" | sed 's/\t\([^"\t]\+\)/\t"\1"/g' | sed 's/\([^"\t]\+\)\t/"\1"\t/g' | # replace empty with null, sed 's/\t\t/\tnull\t/g' | sed 's/\t\t/\tnull\t/g' | sed 's/\t$/\tnull/g' | sed 's/^\t/null\t/g' | tr "\t" , | # and add parens around each line sed 's/^/(/g' | sed 's/$/),/g'