So I have a script that creates a CSV file looking like this:
Timestamp,Latitude,Longitude,MinSeaLevelPressure,MaxIntensity
1800 UTC MAY 16,
0000 UTC MAY 17,
0600 UTC MAY 17,
1200 UTC MAY 17,
1800 UTC MAY 17,
0000 UTC MAY 18,
0600 UTC MAY 18,
1200 UTC MAY 18,
1800 UTC MAY 18,
0000 UTC MAY 19,
0600 UTC MAY 19,
1200 UTC MAY 19,
1800 UTC MAY 19,
0000 UTC MAY 20,
0600 UTC MAY 20,
1200 UTC MAY 20,
1800 UTC MAY 20,
0000 UTC MAY 21,
What I would like to do is edit my code so that I can add data from another file looking like the second image below and append it to the end of each line so it matches up.
28.0
28.9
29.6
30.3
31.0
31.9
33.1
34.4
35.5
36.2
36.8
37.0
36.9
36.2
35.5
34.6
33.7
32.8
My current code is here:
#! /bin/bash
inputFileString=$1
outputFileString=$2
touch "$2"
chmod 755 "$2"
echo "" > lat.txt
sed -i '1d' lat.txt
rm $2
test=(0,1,2,3,4,5,6,7,8,9)
echo "Converting $inputFileString -> $outputFileString ..."
echo "" > $2
awk -F '[<>]' '/<lat>/ {print $3}' $1 >> lat.txt
grep -Eo '<dtg>.*</dtg>' $1 | cut -c 6-20 >> $2
sed -i 's/$/,/' $2
#awk '{print $0, "$variable"}' $2 >> $2
#awk -F '[<>]' '/<lon>/ {print $3}' $1 >> $2
sed -i '1d' $2
sed -i '1i Timestamp,Latitude,Longitude,MinSeaLevelPressure,MaxIntensity' $2
echo Done!
Just for reference my code takes in an input of a kml file and extracts specific data and uses that data to produce a csv file.
{}
icon.xmlstartlet
) or XML parsing library for your preferred programming language (e.g. perl, python, whatever) to extract all the data fields you require and output them in CSV format. Also BTW, your question is quite similar to another question from earlier today, also asking about extracting data from a KML file, you may find useful info there: unix.stackexchange.com/questions/694397/…