Last active
June 27, 2019 14:28
-
-
Save jacargentina/b588e48eb5e875cf30066de10d58d605 to your computer and use it in GitHub Desktop.
Convert dbf to csv, with headings!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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