Okey I managed to solve thisone on my own. Ended up with 2 list and 1 tupple I think . om not that good at syntax so bare with me.
I created one list with my fruite one list with my errormsg and one list with my sekvens and the index of the fruite from the fruite list and the index of the errormsg from the errormsg list me a list that I later on can sort by index ...
[code] DataLoop=[] feltyper=[] modeltyp=[]
def openfile(): f=open(logg,'r') file = f.readlines() f.close for line in open(logg): if len(line)>142: grab= (line) sekvens = grab[31:38] fruit= grab[39:47] errormsg= grab[161:] if feltyp in feltyper: num=int(feltyper.index(feltyp)) else: feltyper.append(feltyp) num=int(feltyper.index(feltyp)) if model in modeltyp: nummod=int(modeltyp.index(model)) else: modeltyp.append(model) nummod=int(modeltyp.index(model)) DataLoop.append((nummod,sekvens,num))[/code]
Thers probebly a 100 better ways to solve this, and if you have any pointers on my code. Please dont by scared to critesis it . And yes, it probebly would be easyer to use a class for this, but I dont understand how to use classes even though I have spent more then a couple of hourese reading dummie manuels =S. So if you want to take it as your assaignment to explain class so I understan Id bee more then happy for you to give it a try.
Comments
f=open(logg,'r')
file = f.readlines()
f.close
Data={}
feltypen=()
for line in open(logg):
if len(line)>142:
grab= (line)
#d
Ended up with 2 list and 1 tupple I think
I created one list with my fruite
one list with my errormsg
and one list with my sekvens and the index of the fruite from the fruite list and the index of the errormsg from the errormsg list me a list that I later on can sort by index
[code]
DataLoop=[]
feltyper=[]
modeltyp=[]
def openfile():
f=open(logg,'r')
file = f.readlines()
f.close
for line in open(logg):
if len(line)>142:
grab= (line)
sekvens = grab[31:38]
fruit= grab[39:47]
errormsg= grab[161:]
if feltyp in feltyper:
num=int(feltyper.index(feltyp))
else:
feltyper.append(feltyp)
num=int(feltyper.index(feltyp))
if model in modeltyp:
nummod=int(modeltyp.index(model))
else:
modeltyp.append(model)
nummod=int(modeltyp.index(model))
DataLoop.append((nummod,sekvens,num))[/code]
Thers probebly a 100 better ways to solve this, and if you have any pointers on my code. Please dont by scared to critesis it
And yes, it probebly would be easyer to use a class for this, but I dont understand how to use classes even though I have spent more then a couple of hourese reading dummie manuels =S. So if you want to take it as your assaignment to explain class so I understan Id bee more then happy for you to give it a try.