Playing with a comparison of python vs. c++ for something simple. stats.py reads lines on stdin and outputs some json, and goc.cpp reads stdin and outputs csv. I may just go with csv for the project but I'll see what json is like in C++ too.

This commit is contained in:
Zed A. Shaw 2024-05-04 00:08:47 -04:00
parent 6a777e4c2d
commit 567ffec4ac
7 changed files with 314 additions and 0 deletions

21
PPP3/stats.py Normal file
View file

@ -0,0 +1,21 @@
import sys
import re
import json
from datetime import datetime
err_re = re.compile("(?P<file>.*?):(?P<line>[0-9]+):(?P<col>[0-9]+): (?P<type>.*?): (?P<message>.*)\n")
stats = [];
for line in sys.stdin:
found = err_re.fullmatch(line)
print(line, end="")
if found:
stats.append(found.groupdict())
print("FOUND", found.groupdict())
with open("stats.json", "a+") as out:
out.write(json.dumps({"date": datetime.now().isoformat(),
"messages": stats}));
out.write("\n")