Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
- The problem statement, all variables and given/known data:
my data in csv-format ...
...
13/08/2012,16:30,303.30,5.10,3,2,2,1,9360.0,322
13/08/2012,16:40,305.50,5.00,3,2,2,1,12360.0,322
13/08/2012,16:50,319.90,3.80,3,2,1,0,2280.0
13/08/2012,17:00,326.10,3.50,3,2,1,1,4380.0,321
13/08/2012,17:10,333.00,3.80,3,3,1,0,2280.0
13/08/2012,17:20,330.20,4.50,3,3,2,0,2700.0
13/08/2012,17:30,332.00,4.20,3,3,2,1,5220.0,332
13/08/2012,17:40,334.90,3.20,3,3,1,0,1920.0
13/08/2012,17:50,337.30,3.10,3,3,1,1,3780.0,331
13/08/2012,18:00,343.20,2.20,3,3,1,1,5100.0,331
13/08/2012,18:10,345.20,1.30,3,3,1,1,5880.0,331
13/08/2012,18:20,340.70,1.60,3,3,1,1,6840.0,331
...
finally i want to display the three-number -index in the last collumn in a gnuplot-graf. Depending from the first number should be chosen a different color. Herefor i want do prepare the data with the awk-script, so that i achive ...
...
08/13/12-16:30 \t \t 322 \t
08/13/12-16:40 \t \t \t 422
08/13/12-16:50 \t \t \t \t
08/13/12-17:00 \t \t 321 \t
08/13/12-17:10 \t \t \t \t
08/13/12-17:20 \t \t \t \t
08/13/12-17:30 \t \t 322 \t
08/13/12-17:40 \t \t \t \t
08/13/12-17:50 \t \t 321 \t
08/13/12-18:00 131 \t \t \t
08/13/12-18:10 \t \t 322 \t
08/13/12-18:20 \t 231 \t \t
...
- Relevant commands, code, scripts, algorithms:
here a awk-script changes the date and time-format
cd $home
if test -f "$f"
then
awk '{FS=","; print substr($1, 4, 2) "/" substr($1, 1, 2) "/" substr($1, 9, 2) "-" $2 "\t" $10}' $home/$f > index.txt
else
DAT=$(date +%Y%m%d)
printf "$DAT - Datei $i nicht vorhanden" >> "$home/Logfiles/Log_$(date +%Y%m%d).log"
fi
08/13/12-16:30 322
08/13/12-16:40 422
08/13/12-16:50
08/13/12-17:00 321
08/13/12-17:10
08/13/12-17:20
08/13/12-17:30 332
08/13/12-17:40
08/13/12-17:50 331
08/13/12-18:00 131
08/13/12-18:10 331
08/13/12-18:20 231
- The attempts at a solution (include all code and scripts):
i tried to upgrade the script to seperate the triplet in column 3
#!/bin/bash
f=APS-Index_20120101_20120814.dat
home=$HOME/Desktop/Bachelor_Projekt/APS3321/Messdaten/APS_AUSWERTUNG_TRIPLET-Daten
cd $home
if test -f "$f"
then
awk -F"," '{
if($10 > 400)
print substr($1, 4, 2) "/" substr($1, 1, 2) "/" substr($1, 9, 2) "-" $2 "\t\t\t" $10 $home/$f > index.txt;
else if ($10 < 400 && $10 > 300)
print substr($1, 4, 2) "/" substr($1, 1, 2) "/" substr($1, 9, 2) "-" $2 "\t\t" $10 "\t" $home/$f > index.txt;
else if ($10 < 300 && $10 > 200)
print substr($1, 4, 2) "/" substr($1, 1, 2) "/" substr($1, 9, 2) "-" $2 "\t" $10 "\t\t" $home/$f > index.txt;
else if ($10 < 200 && $10 > 100)
print substr($1, 4, 2) "/" substr($1, 1, 2) "/" substr($1, 9, 2) "-" $2 "\t" $10 "\t\t\t" $home/$f > index.txt;
else
print substr($1, 4, 2) "/" substr($1, 1, 2) "/" substr($1, 9, 2) "-" $2 "" $home/$f > index.txt;
}'
else
DAT=$(date +%Y%m%d)
printf "$DAT - Datei $i nicht vorhanden" >> "$home/Logfiles/Log_$(date +%Y%m%d).log"
fi
I tried to do it with the above named awk if-statement, but it will not work like this.
Can someone please help me to do it the right way.
Thanks in advance!
IMPe
- Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
University of Applied Sciences Aachen, Germany, Prof.Dr.Helsper, Bachelor Thesis
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).