Perl and Python have syntax options that are similar to the style of awk. The style was described to me as filter thinking. These were not tested on real data.
The awk program translates to
#!/usr/bin/perl
while (<>) {
push @freq, (split)[2..-1] if /Frequencies/;
push @fc, (reverse(split))[3..-1] if /Frc consts/;
push @ir, (reverse(split))[3..-1] if /IR Inten/;
}
print "@freq[$_ - 1] $fc[$_] $ir[$_]\n" for 1..@freq;
and in python
#!/usr/bin/env python3
import sys
freq = []
fc = []
ir = []
for line in sys.stdin:
fields = line.split()
if "Frequencies" in line:
freq.extend(fields[2:])
elif "Frc consts" in line:
fc.extend(reversed(fields[3:]))
elif "IR Inten" in line:
ir.extend(reversed(fields[3:]))
The awk program translates to
#!/usr/bin/perl
while (<>) {
}print "@freq[$_ - 1] $fc[$_] $ir[$_]\n" for 1..@freq;
and in python
#!/usr/bin/env python3
import sys
freq = []
fc = []
ir = []
for line in sys.stdin:
for i in range(len(freq)):