improved handling of addresses and spaced them out to more columns

This commit is contained in:
btmccrea committed 2023-01-20 11:09:13 -05:00
1 parent c89f61366c
commit 612943e9f8
1 file changed
+11 -5
+11 -5
View File
@@ -30,7 +30,7 @@ done
#Create the csv and headers for the Addresses. It is tab separated.
mkdir $OUTPUTFOLDER/Non_Blank
touch $OUTPUTFOLDER/Non_Blank/Addresses.csv
echo -e "File\tUser\tAddress" > $OUTPUTFOLDER/Non_Blank/kkAddresses.csv
echo -e "File,User,Street,City,State,Zip" > $OUTPUTFOLDER/Non_Blank/Addresses.csv
#Create csv with all the files with missing addresses
mkdir $OUTPUTFOLDER/Missing_Addresses
@@ -40,14 +40,13 @@ echo -e "File\tUser" > $OUTPUTFOLDER/Missing_Addresses/Missing_Addresses.csv
cd $PDFDIR
#FOLDER=$(ls | grep *.pdf)
echo $FOLDER
#echo $FOLDER
#*.pdf represensts All files in the current directory with a pdf extention.
for f in $PDFDIR/*
do
echo "Processing file $f."
#pdftotext converst the file to text and places it in the file name temp
pdftotext "$f" - > TEMP
#cat TEMP
#assigns the lines with relevant values to their variable
USER=$(sed -n '12p' TEMP)
ADDRESS1=$(sed -n '13p' TEMP)
@@ -60,9 +59,16 @@ do
echo -e "Copying file to Missing_Addresses"
cp "$f" "$OUTPUTFOLDER"/Missing_Addresses/
echo -e "$f\t$USER" >> "$OUTPUTFOLDER"/Missing_Addresses/Missing_Addresses.csv
#Adds the row of variables to the csv. >> appends to the file. \t represents tabs
#Adds the row of variables to the csv. >> appends to the file. \t represents tabs
else
echo -e "$f\t$USER\t$ADDRESS1 $ADDRESS2" >> $OUTPUTFOLDER/Non_Blank/Addresses.csv
# Split Addresses
CITY=$(echo $ADDRESS2 | cut -d, -f1)
ADDRESS2=$(echo $ADDRESS2 | sed -e "s/$CITY, //")
STATE=$(echo $ADDRESS2 | cut -d" " -f1)
ZIP=$(echo $ADDRESS2 | cut -d" " -f2)
echo -e "$f,$USER,$ADDRESS1,$CITY,$STATE,$ZIP" >> $OUTPUTFOLDER/Non_Blank/Addresses.csv
cp "$f" $OUTPUTFOLDER/Non_Blank/
echo -e "Copying file to Non_Blank"
fi