results = open(filename, 'r')
line = results.readline()
while line != '':
# results for a single draw
star = line[line.rfind('\t') :]
stars.append(star)
line =results.readline()
'''
while line != '':
main = [line[:line.rfind('\t')]]
mains.append(main)
line =results.readline()
return (mains)
I am using the above script to read from a text file in the format 1,2,3,4,5 tab 9,10new line 6,7,8,9,10 tab 11,12 and am trying to get back [[1,2,3,4,5],[6,7,8,9,10]]The above script gives me [[‘1,2,3,4,5’],[‘6,7,8,9,10’]] -the parentheses prevent me using the data. Forgive me for once again being stupid, but how do I get the list format back from the text file? I did try to read other posts, but haven’t been able to apply the suggestions – too new to this
Many thanks for any help
Try:
EDIT:
For getting both parts of each line, try: