I'm making an program which stores certain data in txt files. I did it like this and it works, but I want to change it to lists, so it's easier to edit stuff inside with list.remove and list.append... This is format I made:
Username:data1:data2:data3:data++
What I want to achieve is:
Username:[data1, data2, data3, data++]
Why I want this?
Because editing data separated with ":" is not "Pythonic way" to do this, so I want to convert them to lists...
I get certain lines using this filter:
textfile = open("%s/CreativePoints/Data/plotovimemberi.txt"%pluginlokacija2, 'r+')
a = filter(lambda x: x.startswith("%s:%s"%(targetplot, userID)), \
textfile.readlines())
So current data file looks like this:
Username:data1:data2
Username1:data134:data453:data6534
Username3:data5345:data678:data111:data434
and so on...
What I want to achieve is:
Username:[data1, data2]
Username1:[data134, data453, data6534]
Username3:[data5345, data678, data111, data434]
and so on...
Why? Because I want to get certain line in file using filter I mentioned above and edit list... So I just need to split lines using "line.split(':')[1]" and get list of data, which I can edit using list.append and list.remove...
Thanks for reading/answering! :)