Blame view
parse.sh
1.3 KB
67cec455c Cleaner build |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
#! /bin/bash cut -d ";" -f 4 data/*.csv | sort | uniq > data/theme.txt THEMES=$(cat data/theme.txt | tr " " ",") CATEGORIES=$(grep -o -E "^[^(]*" categorie.txt | sed "s/ $//" | tr " " ",") THEMES=$(echo $THEMES | sed "s/,/\",\"/g" | sed "s/^/\"/" | sed "s/,\"$//") CATEGORIES=$(echo $CATEGORIES | sed "s/,/\",\"/g" | sed "s/^/\"/" | sed "s/,\"$//") echo $THEMES > data/csv.theme echo $CATEGORIES > data/csv.cat FORMATION=$1 echo -n $FORMATION echo -n -e " (" echo -n $(cut -d ";" -f 3 $FORMATION | paste -sd+ | bc) echo " ECTS)" > $FORMATION.theme > $FORMATION.cat echo -e "\tPar thème" IFS='' cat data/theme.txt | while read THEME do echo -n -e "\t\t$THEME " ECTS=$(grep $THEME$ $FORMATION | cut -d ";" -f 3) if [[ -z "$ECTS" ]] then ECTS=0 fi ECTS=$(echo $ECTS | tr ' ' ' ' | paste -sd+ | bc) THEMES_ECTS=$THEMES_ECTS,$ECTS echo -n "$ECTS," >> $FORMATION.theme echo $ECTS done sed -i "s/,$/ /" $FORMATION.theme echo -e "\tPar catégorie" IFS='' cat categorie.txt | while read CAT do CATEGORIE=$(echo $CAT | grep -o -E "^[^(]*") PATT=$(echo $CAT | grep -o "(.*)") echo -n -e "\t\t$CATEGORIE" ECTS=$(grep -E $PATT$ $FORMATION | cut -d ";" -f 3 | paste -sd+ | bc) echo -n "$ECTS," >> $FORMATION.cat echo $ECTS done sed -i "s/,$/ /" $FORMATION.cat |