From ce1c82de0f8d749f2f7fdef267c1721cd1a434a0 Mon Sep 17 00:00:00 2001 From: Kévin Raymond Date: Thu, 24 Oct 2013 19:21:55 +0000 Subject: rename txt files that compiled from JSON activities --- diff --git a/parse.sh b/parse.sh index 6a97478..079f4f0 100755 --- a/parse.sh +++ b/parse.sh @@ -88,7 +88,27 @@ do else if [ $ext == 'txt' ] then - grep -q 'Madagascar.activity' ../data && ext="madagascar" + cat ../data | json_verify -q + # A txt file might be written by the children, or an activity. + # The activity write the content following the JSON format. + if [ $? -eq 0 ] + then + ext='txt.act' + grep -q 'Madagascar.activity' ../data && ext="madagascar" + else # Handle special format + # No JSON but something containing [report/YYYY.... + grep -q "^\[report/20" ../data && ext='txt.act' + # No JSON but always containing 1 number per line on 3 lines + grep -q "^\d*" ../data + if [ $? -eq 0 ] + then + w=`wc -lw ../data | awk '{print $1$2}'` + if [ $w -eq '33' ] + then + ext='txt.act' + fi + fi + fi fi cp -a ../data $out/datastore/$int.$ext -- cgit v0.9.1