Page MenuHomec4science

check_list
No OneTemporary

File Metadata

Created
Fri, May 31, 08:04

check_list

#!/bin/bash
function USAGE() {
echo "USAGE: $0 csv_list.csv";
exit 1
}
SOURCE=$1
if [ ! -r $SOURCE ]; then echo "File not found: $SOURCE" >2; USAGE; fi
function fetch_data() {
local sciper=$1
local cache_file="./cache/${sciper}.txt"
if [ ! -f $cache_file ]; then
./search-epfl -s $sciper > $cache_file
DATA=$(./search-epfl -s $sciper | tr '\n' '~');
fi
DATA=$(cat $cache_file | tr '\n' '~')
}
function get_field() {
local field=$1
echo $DATA | tr '~' '\n' | grep "^$field:" | cut -d ':' -f 2-
}
IFS=$'\n'
id=0
for l in $(cat $1); do
((id++))
sciper=$(echo $l | cut -d ',' -f 1)
rest=$(echo $l | cut -d ',' -f 2-)
fetch_data $sciper
section=$(get_field 'section')
name=$(get_field 'cname_usual')
status="OK";
if [ -z "$section" ] ; then section=$(echo $l | cut -d ',' -f 3); status="NOT FOUND"; fi
if [ -z "$name" ] ; then name=$(echo $l | cut -d ',' -f 2); fi
echo "$id,$sciper,$name,$section,$status,$rest"
done

Event Timeline