citadel2server.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. #fin=(ParkingGR.xlsx.json Greece Trnasportation)
  3. file_in="/Data/citadel.csv"
  4. file_out="/Data/citadel.xml"
  5. function element() {
  6. h3=${h7//\"/$h5}
  7. h3=${h3#*$1+:+}
  8. h3=${h3%%+*}
  9. echo "<$2>${h3}</$2>" >> $file_out
  10. }
  11. IFS="*"
  12. while read link country waze osm comment
  13. do
  14. echo $link
  15. file_name=../Temp/${link##*/}
  16. #echo $file_name
  17. echo $country
  18. echo $waze
  19. file_out="../Temp/temporary.xml"
  20. #file_out="../Temp/"${comment}'.xml'
  21. #echo $file_out
  22. #cd ../Temp/
  23. wget -P ../Temp/ --output-document=../Temp/temporary1.json ${link}
  24. sed -r 's/&+/&amp;/g' ../Temp/temporary1.json > ../Temp/temporary.json
  25. #awk 'BEGIN { FS="&"; OFS="and" } {$1=$1; print}' ../Temp/temporary1.json > ../Temp/temporary.json
  26. echo '<?xml version="1.0"?>' > $file_out
  27. echo '<Root name="'${comment}'" country="'${country}'" waze="'${waze}'" osm="'${osm}'">' >> $file_out
  28. input=${file_name[0]}
  29. #read -r line < ${file_name[0]}
  30. read -r line < ../Temp/temporary.json
  31. h1="*"
  32. h5="+"
  33. line=${line//'},{'/$h1}
  34. line=${line//':[{'/$h1}
  35. IFS='*' read -r -a array <<< "$line"
  36. echo ${array[0]}
  37. h7=${array[0]//\"/$h5}
  38. idset=${h7%%,*}
  39. echo $id
  40. idset=${idset##*:}
  41. echo $id
  42. echo '<id>'${h3}'</id>' >> $file_out
  43. for ((i=1; i < ${#array[@]}; i++))
  44. do
  45. echo '<Item>' >> $file_out
  46. echo '<idset>'$idset'</idset>' >> $file_out
  47. h7=${array[i]//\"/$h5}
  48. element id id
  49. element title label
  50. element value addr_city
  51. element posList coord
  52. echo '</Item>' >> $file_out
  53. done
  54. echo '</Root>' >> $file_out
  55. java -Djava.io.tmpdir=../Temp -Xms2560m -Xmx24560m -jar saxon9he.jar -s:../Temp/temporary.xml -xsl:../XSLT/transform_citadel.xsl -o:../RDF_output/${comment}_Citadel.rdf -t
  56. done < $file_in
  57. cd