#!/bin/bash # This script generates a CSV file that mimics Facebook's donation export CSV file # to be used for generating practice Powerbase import files. random_number() { local start="$1" local end="$2" local modulus=$(( "$end" - "$start" - 1 )) echo $(( $RANDOM % "$modulus" + "$start" )) } random_timestamp_last_month() { # 43,200 minutes in a month. local minutes_ago=$(random_number 1 43200) echo $(date -d "${minutes_ago} minutes ago" "+%s") } # Output the headers printf "Payment ID," printf "Charge Time," printf "Donation Amount," printf "FB Fee," printf "Net Payout Amount," printf "Payout Currency," printf "Sender Currency," printf "Tax Amount," printf "Tax USD Amount," printf "Charge Action Type," printf "Charge Date," printf "First Name," printf "Last Name," printf "Email Address," printf "Campaign ID," printf "Fundraiser Title," printf "Source Name," printf "Permalink," printf "Charity ID," printf "Campaign Owner Name," printf "Payment Processor," printf "Matching Donation\n" girl_names=$(http 'http://names.drycodes.com/10?nameOptions=girl_names' | grep '_' | tr -d '[]"' ) #echo $boy_names for num in $(seq 1 10); do name=$(echo "$girl_names" | cut -d, -f${num}) payment_id=$(random_number 100000 999999) charge_time=$(random_timestamp_last_month) donation_amount=$(random_number 10 500) fb_fee=0 net_payment_amount="$donation_amount" payout_currency="USD" sender_currency="USD" tax_amount=0 tax_usd_amount=0 charge_action="S" charge_date=$(date -d @"$charge_time" "+%m/%d/%y") first_name=$(echo "$name" | cut -d_ -f1) last_name=$(echo "$name" | cut -d_ -f2) email_address="${first_name}.${last_name}.face@example.net" campaign_id="1234567" fundraiser_title="Support our great campaign" source_name="fundraiser" permalink="https://www.facebook.com/123" charity_id="456" campiagn_owner_name="" payment_processor="facebook" matching_donation="no" printf "%d0000000000,%d,%d,%d,%d,%s,%s,%d,%d,%s,%s,%s,%s,%s,%d,%s,%s,%s,%d,%s,%s,%s\n" \ "$payment_id" \ "$charge_time" \ "$donation_amount" \ "$fb_fee" \ "$net_payment_amount" \ "$payout_currency" \ "$sender_currency" \ "$tax_amount" \ "$tax_usd_amount" \ "$charge_action" \ "$charge_date" \ "$first_name" \ "$last_name" \ "$email_address" \ "$campaign_id" \ "$fundraiser_title" \ "$source_name" \ "$permalink" \ "$charity_id" \ "$campiagn_owner_name" \ "$payment_processor" \ "$matching_donation" done