[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Again problems with the creation of tables...
- From: meino.cramer@...
- Date: Fri, 25 Oct 2013 21:06:22 +0200
Hi,
this is the "extend version" of my previous question...so to say...
I have a pure ASCII table like this (example):
kldjs oipjnciobro iboie rnq ciowjboijebo ijwe ocnqweocnj oe qnocejqno
ifowe jfoiwejfoim wepfj wen pfonwepfnwpe ofjm pweofpowej mf pejmfmpfo
cwyqt scfwysfyqts fytqw fcd tyqwfcdytqwf cdyq wfdytwfdyf cw ydfqwycdy
hiotn jorjnhortjh ortho rtj hrtnjhoirnto ihnr thnortnhjo ir tnjhrtnjh
okmem kldpmodqmop dqwop mwd qopmdwopmdwo pmwd opmwdmopdw om pdwopwdmo
tvvuy uvywquyvwdq uywdq uyu yvwdqyvuvywd yuqw dvuyvuyyvu wd qyvuwdqyv
omqwd mwdqmomwdql kfnmj fpp foejwpfnwepo fpew omfpoeoiho ih qdjqpkdqk
The columns are named (example) AAA,BBB,CCC,DDD,EEE,FFF,GGG,HHH,III
(In reality the table contains real world data of about 10000 lines
and about 20 columns. The columns names reflect the meaning of their
data.)
In a lua table I have stored the layout of the table:
layout={
AAA={1,5}.
BBB={7,17}
CCC={19,23
DDD...
EEE...
FFF...
GGG...
HHH...
III...
}
("..." =: and so forth)
Now: Since the contents of the columns can apear more than once in a
column, I want to dynamically create a table, which name is the name of
the column and which key is the column value
(this way double entries will be removed automagically), and which
value is a counter how often this key/column value was found.
I got some interesting side effects and rubbish, but no working code.
This is what I have so far:
fields={
AAA = { 1 , 11 },
BBB = { 13 , 19 },
CCC = { 21 , 27 },
DDD = { 29 , 30 },
EEE = { 32 , 50 },
FFF = { 52 , 55 },
CCC = { 57 , 100 },
DDD = { 102 , 110 },
EEE = { 112 , 114 },
FFF = { 116 , 120 },
GGG = { 122 , 123 },
HHH = { 124 , 127 },
III = { 128 , 144 },
JJJ = { 146 , 148 },
KKK = { 150 , 152 },
LLL = { 154 , 169 },
MMM = { 171 , 175 },
NNN = { 177 , 180 },
OOO = { 182 , 184 },
PPP = { 186 , 200 },
QQQ = { 202 , 211 },
RRR = { 213 , 120 },
SSS = { 222 , 150 },
}
data={}
for i,v in pairs(fields) do
-- "data.txt" the columns with values
fh=io.open( "data.txt","r" )
index=fields[i]
first=index[1]
last=index[2]
for line in fh:lines() do
text=string.sub( line, first, last )
data[i][text]=1
end
io.close( fh )
end
But this dont do, what I have described above.
I tried several permutation with different result,
but no result matches what want to implement.
How can I achieve the wanted results?
Thank you very much in advance!
Best regards,
mcc