0
The title of the question refers to csv because it is widely used and has the same logic but my server produces the following output:
ifname | username | calling-sid | ip | type | comp | state | uptime
---------+------------------------+-------------------+-----------------+-------+------+--------+------------
ppp10 | anamariade | 00:1A:3F:74:03:93 | 10.10.10.3 | pppoe | | active | 7.02:26:48
ppp365 | fabianepinow | 98:DE:D0:FF:AE:C1 | 10.10.10.112 | pppoe | | active | 6.19:21:57
ppp621 | nilsonbrito | 78:44:76:8D:57:07 | 10.10.10.77 | pppoe | | active | 6.19:21:31
ppp405 | andreparente | DC:9F:DB:EE:CA:24 | 10.10.10.232 | pppoe | | active | 6.16:54:32
I want every line pppX
is an index of the table and within the table its respective columns: tab[0].username
tab[0].ip
, I’ve read the manual but the way I did the indexes don’t match:
local tabfinal = {} // declara uma nova tabela
local saida = es.abra("saida.txt","leitura") // abrindo o arquivo
local texto = saida:leia("*t") // lê todo conteúdo
local tabtemp = texto:analise("|") // quebraria o texto em vários índices
para i,v em pares(tabtemp) inicio // laço para preencher a tabela final
se nao v:procure("|") entao // testa o separador
tabela.insira(tabfinal,1,v) // alimenta a tabela
fim
fim
Your code was well worked out! Here I was able to do only one string:analyze("|") and fill the table from the second index.
– Rafael Lemos