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

31
PPP3/goc.cpp Normal file
View file

@ -0,0 +1,31 @@
#include <iostream>
#include <fmt/core.h>
#include <regex>
#include <string>
#include <iterator>
using namespace std;
using namespace fmt;
int main()
{
regex err_re("(.*?):([0-9]+):([0-9]+):\\s*(.*?):\\s*(.*)");
string line;
smatch err_match;
while(getline(cin, line)) {
print("{}\n", line);
if(regex_match(line, err_match, err_re)) {
string file_name = err_match[1].str();
string line = err_match[2].str();
string col = err_match[3].str();
string type = err_match[4].str();
string message = err_match[5].str();
print("{},{},{},{},{}\n",
file_name, line, col, type, message);
}
}
return 0;
}