Skip to main content
added 1107 characters in body
Source Link
locometro
  • 861
  • 5
  • 15

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"}}]

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.

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"}}]
Major clean-up
Source Link
m_goldberg
  • 108.1k
  • 16
  • 104
  • 259

import importing a table from txta file and editing it using string patternspattern functions

I am trying to make a table (or grid), from a txt outputtext file:    filetemplate

First step, I tried to get the numbers and stringsthe related to,strings using the following code:

  tab1 = FindList[
   "CFindList["C:\\Users\\MARCELO\\..........\
.....txt", {"inmetro", "ufrj", "colaborador"}];

DeleteCases[tab1, {_String?(StringMatchQ[#, 
      "Submetido"] &), ___}, Infinity]

But, it does not workswork.

theThe heads table in the txttext 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

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"] ", doStringMatchQ[#, "Submetido"]& not recognize that string, in order to erase the lines that are not neededstring "Submetido"?

I read some similar questions here, but they are not so useful on thatmy issue.

import a table from txt file using string patterns functions

I am trying make a table (or grid), from a txt output file:  filetemplate

First step, I tried to get the numbers and strings related to, using the following code:

  tab1 = FindList[
   "C:\\Users\\MARCELO\\..........\
.....txt", {"inmetro", "ufrj", "colaborador"}];

DeleteCases[tab1, {_String?(StringMatchQ[#, 
      "Submetido"] &), ___}, Infinity]

But, it not works.

the heads table in the txt 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 " (StringMatchQ[#, "Submetido"] ", do not recognize that string, in order to erase the lines that are not needed?

I read similar questions, but they are not so useful on that issue.

importing a table from a file and editing it using string pattern functions

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.

Source Link
locometro
  • 861
  • 5
  • 15

import a table from txt file using string patterns functions

I am trying make a table (or grid), from a txt output file: filetemplate

First step, I tried to get the numbers and strings related to, using the following code:

  tab1 = FindList[
   "C:\\Users\\MARCELO\\..........\
.....txt", {"inmetro", "ufrj", "colaborador"}];

DeleteCases[tab1, {_String?(StringMatchQ[#, 
      "Submetido"] &), ___}, Infinity]

But, it not works.

the heads table in the txt 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 " (StringMatchQ[#, "Submetido"] ", do not recognize that string, in order to erase the lines that are not needed?

I read similar questions, but they are not so useful on that issue.