I wrote a function which takes a .txt file.
The first thing it does is split the file at ',' and add them to a list, which creates a list of lists.I used:
lst = s.split(',')
I do get a list of lists, except every second line has an empty list ['\n']. I need to find a way get rid of these empty lists as they muck up the rest of the code.
Is there any simple way of doing this? Or is it just that I doing something wrong?
Any help would be greatly appreciated. Thank You!
Sample Data:
1,2,3,4
,3,4,
Expected Output:
['1','2','3','4\n']
['','3','4','\n']
Current Output:
['1','2','3','4\n']
['\n']
['','3','4','\n']
Output after using sshashank124's suggestion:
['1','2','3','4\n']
[]
['','3','4','\n']
Output after using Alex Thornton's suggestion:
['1','2','3','4\n']
[]
['','3','4','\n']