tuple of list/tuple pointing to list - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

tuple of list/tuple pointing to list

sverkerlarsonsverkerlarson Posts: 4Member
[code] logg = 'c:\tmp\Logg\12-12-13.txt'
f=open(logg,'r')
file = f.readlines()
f.close
Data={}
feltypen=()

for line in open(logg):

if len(line)>142:
grab= (line)
#d

Comments

  • sverkerlarsonsverkerlarson Posts: 4Member
    [code][code] logg = 'c:\tmp\Logg\12-12-13.txt'
    f=open(logg,'r')
    file = f.readlines()
    f.close
    Data={}
    feltypen=()

    for line in open(logg):

    if len(line)>142:
    grab= (line)
    #d
  • sverkerlarsonsverkerlarson Posts: 4Member
    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.
Sign In or Register to comment.