Skip to content

Instantly share code, notes, and snippets.

@jacargentina
Last active June 27, 2019 14:28
Show Gist options
  • Save jacargentina/b588e48eb5e875cf30066de10d58d605 to your computer and use it in GitHub Desktop.
Save jacargentina/b588e48eb5e875cf30066de10d58d605 to your computer and use it in GitHub Desktop.
Convert dbf to csv, with headings!
#!/bin/sh
if [ -z "$1" ]
then
echo "./dbf2csv [file.dbf]"
exit
fi
for var in "$@"
do
dbfdump.pl --info $var | csplit - 10 -s
HEADING=$(cut -f2 xx01 | cut -f1 -d' ' | tr '\n' ',')
HEADING=${HEADING%?}
rm xx*
FILENAME=$(basename $var .dbf)
echo $HEADING > $FILENAME.csv
dbfdump.pl --fs ',' $var >> $FILENAME.csv
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment