Skip to content

Instantly share code, notes, and snippets.

@morsecodemedia
Created October 30, 2017 14:06
Show Gist options
  • Save morsecodemedia/4e6313020fffee8d2df3f7732e94dc52 to your computer and use it in GitHub Desktop.
Save morsecodemedia/4e6313020fffee8d2df3f7732e94dc52 to your computer and use it in GitHub Desktop.
Import Clickstream Data for Analytics
#!/bin/sh
###### Check for badly named files next #######
# Possible names for Clickstream Report
for clickstream in "./Digital Content Clickstream Data" "./Digital Content Clickstream Data Report" "./Digital Content Clickstream Report"
do
if [ -f "$clickstream.xls" ] ; then
echo "$clickstream.xls is an Excel file. Please convert to CSV first"
fi
if [ -f "$clickstream.xlsx" ] ; then
echo "$clickstream.xlsx is an Excel file. Please convert to CSV first"
fi
if [ -f "$clickstream.csv" ] ; then
mv "$clickstream.csv" callstreamImport.csv
fi
done
# Possible names for Key Message Report
for key in "./NBU Call Key Message Data" "./NBU Call Key Message data" "./NBU Call Key Message" "./NBU Call Key Message Report" "./NBU Call Key Message report"
do
if [ -f "$key.xls" ] ; then
echo "$key.xls is an Excel file. Please convert to CSV first"
fi
if [ -f "$key.xlsx" ] ; then
echo "$key.xlsx is an Excel file. Please convert to CSV first"
fi
if [ -f "$key.csv" ] ; then
mv "$key.csv" keymessageImport.csv
fi
done
# Possible names for Approved Email Report
for email in "./Approved Email report for NBU and GI" "./Approved Email report for GI and NBU" "./Approved Email report for GI and NBU Report"
do
if [ -f "$email.xls" ] ; then
echo "$email.xls is an Excel file. Please convert to CSV first"
fi
if [ -f "$email.xlsx" ] ; then
echo "$email.xlsx is an Excel file. Please convert to CSV first"
fi
if [ -f "$email.csv" ] ; then
mv "$email.csv" approvedemailImport.csv
fi
done
###### Clean, then send the files to the server and run the import scripts #######
if [ -f "./callstreamImport.csv" ] ; then
sed -i '/^,/Q' callstreamImport.csv # trim trash footer
scp callstreamImport.csv tomasino@dev.gsw-w.com:/var/www/dev.gsw-w.com/automation/callstreamImport.csv
ssh tomasino@dev.gsw-w.com /var/www/dev.gsw-w.com/automation/callstreamImport.sh
fi
if [ -f "./keymessageImport.csv" ] ; then
sed -i '/^,/Q' keymessageImport.csv # trim trash footer
scp keymessageImport.csv tomasino@dev.gsw-w.com:/var/www/dev.gsw-w.com/automation/keymessageImport.csv
ssh tomasino@dev.gsw-w.com /var/www/dev.gsw-w.com/automation/keymessageImport.sh
fi
if [ -f "./approvedemailImport.csv" ] ; then
sed -i '/^,/Q' approvedemailImport.csv # trim trash footer
scp approvedemailImport.csv tomasino@dev.gsw-w.com:/var/www/dev.gsw-w.com/automation/approvedemailImport.csv
ssh tomasino@dev.gsw-w.com /var/www/dev.gsw-w.com/automation/approvedemailImport.sh
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment