Created
June 1, 2015 01:41
-
-
Save whyvez/3d651cf4b3255c97e2c0 to your computer and use it in GitHub Desktop.
PGYI fkey checker
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
| #!/usr/bin/env bash | |
| # checks pgyi dataset for fkey integrity | |
| # will print out any offending records | |
| # usage: bash ./fkeycheck.sh <csv_data_folder> | |
| # example: bash ./fkeycheck.sh ./examples/pgyi/data | |
| wd=$1 | |
| plot=$wd/plot.csv | |
| plot_measurement=$wd/plot_measurement.csv | |
| trees=$wd/trees.csv | |
| trees_measurement=$wd/trees_measurement.csv | |
| treatment=$wd/treatment.csv | |
| disturbance=$wd/disturbance.csv | |
| regeneration=$wd/regeneration.csv | |
| photo_avi=$wd/photo_avi.csv | |
| plot_childs=($plot_measurement $trees $treatment $disturbance $regeneration $photo_avi) | |
| check(){ | |
| awk -F, "NR==FNR{ k[$2]=1; next; } NF{ if(!k[$4]) print; }" $1 $3 | |
| } | |
| for child in "${plot_childs[@]}" | |
| do | |
| check $plot '$1 $2' $child '$1 $2' | |
| done | |
| check $trees '$1 $2 $3' $trees_measurement '$1 $2 $4' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment