3 ms·
> python code that's almost deliberately atrocious That code was so bad I felt I had to step in too, I used chatGPT to simplify it a bit but it also introduced
by elesiuta 4y ago
> python code that's almost deliberately atrocious
That code was so bad I felt I had to step in too, I used chatGPT to simplify it a bit but it also introduced some errors, so I found what appears to be an input file to test it on [1]. The only difference with the awk program is that it uses spaces while the original python program used tabs.
#!/usr/bin/env python3
import sys
freq, fc, ir = [], [], []
with open(sys.argv[1]) as f:
for line in f.readlines():
words = line.split()
if "Frequencies" in line:
freq.extend(words[2:])
elif "Frc consts" in line:
fc.extend(words[3:])
elif "IR Inten" in line:
ir.extend(words[3:])
for i in range(len(freq)):
print(f"{freq[i]}\t{fc[i]}\t{ir[i]}")
[1] https://dornshuld.chemistry.msstate.edu/comp-chem/first-gaussian-job/#:~:text=the%20frequency%20computation.-,Frequency%20Data,-Lines%201097%2D1113 https://dornshuld.chemistry.msstate.edu/comp-chem/first-gaus...
- andrepd 4y ago> I used chatGPT to simplify it a bit but it also introduced some errors Lmaoooo