From a5c2e56ded009fdd55c5ddc12aa1c2a1cec45b9c Mon Sep 17 00:00:00 2001 From: hs7n22 <hs7n22@southampton.ac.uk> Date: Thu, 16 Mar 2023 15:28:02 +0000 Subject: [PATCH] Upload New File --- create_csv.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 create_csv.sh diff --git a/create_csv.sh b/create_csv.sh new file mode 100644 index 0000000..2338606 --- /dev/null +++ b/create_csv.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +#First set 2 variable that extract from kml and save as csv + +kml_output_path=$1 +csv_output_path=$2 + +echo"Timestamp,Latitude,Longitude,MinsealevePressure,MaxIntensity" > $2 + +echo "Create_csv.sh report.kml storm_info.csv" +echo "Converting report.kml -> storm_info.csv..." + +#Second have 5 kml data and get the information we care about with unit +#Here we grep latitude grep longitude grep intensity grep pressure grep timestamp + +lat=$(grep "<lat>" $1 | cut -d ">" -f 2 | cut -d "<" -f 1 | sed "s/$/N/g" >lat.txt) +lon=$(grep "<lon>" $1 | cut -d ">" -f 2 | cut -d "<" -f 1 | sed "s/$/W/g" >lon.txt) +inte=$(grep "<intensity>" $1 | cut -d ">" -f 2 | cut -d "<" -f 1 | sed "s/$/$ Knots/g" > inten.txt) +press=$(grep "<minSea.*>" $1 | cut -d ">" -f 2 | cut -d "<" -f 1 | sed "s/$/& mb/g" > press.txt) +tim=$(grep "<lat>" $1 | cut -d ">" -f 2 | cut -d "<" -f 1 > ts.txt) + +#Third sort data, outupt it aas a csv file +echo "$timestamp,$lat,$lon,$pressure,$intensity" >>$2 + +echo "Done!" + -- GitLab