diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2021-05-07 09:07:20 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2021-05-07 09:07:20 +0200 |
| commit | 9bc9ab691afeeb676ae9b3c386a49c13a453dc0b (patch) | |
| tree | 5a0d86c07202375a48fe844b494bb98299122958 /parser.awk | |
| parent | b7abfc66f0a5a30e9703908c018032d68e65d6b7 (diff) | |
Debug parser and cleaning
Diffstat (limited to 'parser.awk')
| -rwxr-xr-x | parser.awk | 27 |
1 files changed, 21 insertions, 6 deletions
@@ -1,21 +1,24 @@ #!/usr/bin/awk -f BEGIN { - RS=" " + RS="\n" + FS=" " CSV_HEADER="" CSV_DATA="" + # ENERGY created below } /LOG2PARSE/{ # First extract what we need - to_parse=$1 + split($0,fields," ") + to_parse=fields[8] gsub(/\[LOG2PARSE\]\(/,"",to_parse) gsub(/\)/,"",to_parse) split(to_parse,tokens,"|") # Check if we have to build the csv header if(CSV_HEADER==""){ - for(i = 1; i<length(tokens);i++){ + for(i = 1; i<=length(tokens);i++){ split(tokens[i],h,":") if(CSV_HEADER=="") CSV_HEADER=h[1] @@ -26,7 +29,7 @@ BEGIN { # Build a row row="" - for(i = 1; i<length(tokens);i++){ + for(i = 1; i<=length(tokens);i++){ split(tokens[i],h,":") if(row=="") row=h[2] @@ -42,7 +45,19 @@ BEGIN { } +/\[surf_energy\/INFO\] Energy/ { + $7=substr($7, 1, length($7)-1) + ENERGY[$7]=$8 +} + + END { - print(CSV_HEADER); - print(CSV_DATA) + print(CSV_HEADER",energy"); + + # Print data and add up energy values + split(CSV_DATA,rows, "\n") + for(i=1;i<=length(rows);i++){ + split(rows[i],fields, ",") + print(rows[i]","ENERGY[fields[1]]) + } }
\ No newline at end of file |
