From 612943e9f8866bff1792c69021f435540090081d Mon Sep 17 00:00:00 2001 From: btmccrea Date: Fri, 20 Jan 2023 11:09:13 -0500 Subject: [PATCH] improved handling of addresses and spaced them out to more columns --- Find_Missing_Addresses.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Find_Missing_Addresses.sh b/Find_Missing_Addresses.sh index 2d9e0bc..b8ec019 100755 --- a/Find_Missing_Addresses.sh +++ b/Find_Missing_Addresses.sh @@ -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