SHARE
TWEET

Untitled

a guest Oct 21st, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. #Export_Large_Projects tester
  3. if [ $# -lt 2 ]
  4.   then
  5.     echo "USE $0 CSV_FILE SAS_FILE"
  6.     exit 1
  7. fi
  8.  
  9. declare -a EQ_to_CSV=("info_informacin_de_c_v_0"  "f23_registro_contact_v_1"  "f18_actualizacion_in_v_2" "f3_ecografia_abdomin_v_3" "f3_ecografia_abdomin_v_4" "f3_ecografia_abdomin_v_5" "f10_encuesta_de_segu_v_6" "f22_encuesta_colecis_v_7" "f5_pareamiento_segun_v_8" "f4_examen_fisico_seg_v_9" "f22_encuesta_colecis_v_10" "f12_recoleccion_de_e_v_11" "f25_sospecha_cncer_c_v_12" "f11a_revisin_de_fich_v_13" "f11a_revision_de_fic_v_14" "f20_formularios_falt_v_15" "f19_salida_del_estud_v_16")
  10. declare -a EQ_to_SAS=("info_informacin_de_contacto_complete" "f23_registro_contacto_seguimiento_complete" "f18_actualizacion_informacion_de_participante_complete" "f3_ecografia_abdominal_complete" "f3_ecografia_abdominal_segunda_complete" "f3_ecografia_abdominal_tercera_complete" "f10_encuesta_de_seguimiento_complete" "f22_encuesta_colecistectomia_complete" "f5_pareamiento_segundo_complete" "f4_examen_fisico_segundo_complete" "f22_encuesta_colecistectomia_segunda_complete" "f12_recoleccion_de_especimenes_quirurgicos_complete" "f25_sospecha_cncer_clnico_complete" "f11a_revisin_de_ficha_clnica_basal_complete" "f11a_revision_de_ficha_clinica_segunda_complete" "f20_formularios_faltantes_complete" "f19_salida_del_estudio_complete")
  11. CSV=$1
  12. SAS=$2
  13. TMP_CSV="csv.txt"
  14. TMP_SAS="sas.txt"
  15. NOT_FOUND_SAS=0
  16. NOT_FOUND_CSV=0
  17. FOUND=0
  18. RED='\033[0;31m'
  19. NC='\033[0m'
  20. YELLOW='\033[0;33m'
  21. head -n 1 $CSV | tr  ',' '\n' > $TMP_CSV
  22.  
  23. for i in "${EQ_to_CSV[@]}"
  24. do
  25.    echo -n ",$i" >> $TMP_CSV
  26. done
  27.  
  28.  
  29. sed 's/\$//g' $SAS |grep -v "='" |grep -v informat |grep -v format |tail -n +5 | head --lines=-22 > $TMP_SAS
  30. for i in "${EQ_to_SAS[@]}"
  31. do
  32.    echo  "                $i" >> $TMP_SAS
  33. done
  34.  
  35.  
  36. #read csv
  37. echo -e "${RED} In CSV but not in SAS ${NC}"
  38. while read -r lineCSV;
  39.     do
  40.     if grep -q "$lineCSV" $TMP_SAS; then
  41.       #echo "found "
  42.       FOUND=$((FOUND + 1))
  43.      
  44.     else
  45.       echo -e "${YELLOW} $lineCSV ${NC}"
  46.       NOT_FOUND_CSV=$((NOT_FOUND_CSV + 1))
  47.     fi
  48.     done <  $TMP_CSV
  49.  
  50. #read sas
  51.  
  52. echo -e "\n${RED}In SAS but not in CSV${NC}"
  53. FOUND=0
  54. NOT_FOUND=0
  55. while read -r lineSAS;
  56.     do
  57.         if grep -q "$lineSAS" $TMP_CSV; then
  58.           #echo "found "
  59.           FOUND=$((FOUND + 1))
  60.  
  61.         else
  62.           echo -e "${YELLOW} $lineSAS ${NC}"
  63.           NOT_FOUND_SAS=$((NOT_FOUND_SAS + 1))
  64.         fi
  65.     done < $TMP_SAS
  66.  
  67. echo -e  "\nTotal Found: $FOUND"
  68. echo "Total Not Found in SAS: $NOT_FOUND_SAS"
  69. echo "Total Not Found in CSV: $NOT_FOUND_CSV"
  70.  
  71. #cleaning
  72. rm -f $TMP_CSV $TMP_SAS
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top