Nov 5, 2017

Create MySQL table from CSV file header

$ cat

# pass in the file name as an argument: ./ filename.csv
echo "create table $1 ( "
head -1 $1 | sed -e 's/,/ varchar(255),\n/g'
echo " varchar(255) );"

csvkit is a suite of utilities for converting to and working with CSV, the king of tabular file formats. csvkit is to tabular data what the standard Unix text processing suite (grep, sed, cut, sort) is to text.