I am trying to make a table (or grid) from a text file: filetemplate
I tried to get the numbers and the related strings using the following code:
tab1 =
FindList["C:\\Users\\MARCELO\\...\....txt", {"inmetro", "ufrj", "colaborador"}];
DeleteCases[tab1, {_String?(StringMatchQ[#, "Submetido"] &), ___}, Infinity]
But it does not work.
The heads table in the text file template are:
1 - Wallclock Média Média
Usuário Grupo #jobs dias Porcento #nodes q-dias Nome completo
2 - Wallclock Média Média
Grupo #jobs dias Porcento #nodes q-dias
Why does StringMatchQ[#, "Submetido"]&
not recognize the string "Submetido"
?
I read some similar questions here, but they are not so useful on my issue.
EDIT 2 - new code that works for the first table:
tab1 = FindList[
"C:\\............\\...txt", {"inmetro", "ufrj", "colaborador"}];
tab2 = DeleteCases[
tab1, _String?(StringMatchQ[#, ___ ~~ "Inic*",
IgnoreCase -> True] &), Infinity];
tab3 = Flatten[StringSplit[tab2, RegularExpression["\\t+"]]];
tab4 = StringDelete[tab3,
StartOfString ~~ Whitespace ~~
"inmetro" | "ufrj" | "colaborador" ~~ ___];
tab5 = Split[tab4];
Flatten[StringSplit[#, RegularExpression["\\s{2,10}"]] & /@ tab5, 1];
tab6 = Replace[%, x_List :> DeleteCases[x, {}], {0, Infinity}];
For table 2:
tab7 = StringCases[tab3,
StartOfString ~~ Whitespace ~~
"inmetro" | "ufrj" | "colaborador" ~~ ___];
StringSplit[#, RegularExpression["\\s{2,10}"]] & /@ tab7;
tab8 = Flatten[
Replace[%, x_List :> DeleteCases[x, {}], {0, Infinity}], 1];
tabfinal2 =
TableForm[tab8,
TableHeadings -> {None, {"Grupo", "jobs", "Wallclock \n dias", "%",
"Média\n #nodes", "Média\n q-dias"}}]