Debug parser and cleaning

This commit is contained in:
Loic Guegan 2021-05-07 09:07:20 +02:00
parent b7abfc66f0
commit 9bc9ab691a
3 changed files with 33 additions and 18 deletions

View file

@ -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]])
}
}