I have the data in the following format (in a csv file):
a b c
b
a
a c d
b c
b c
I would like to covert the above data to the following format (list):
[['a', 'b', 'c'],
['b'],
['a'],
['a', 'c', 'd'],
['b', 'c'],
['b', 'c']]
I have done this so far:
import csv
fileName = "toydataset.csv"
data = open(fileName, 'r')
reader = csv.reader(data)
allRows = [row for row in reader]
allRows
But, the output looks like this:
[['a', 'b', 'c'],
['b', '', ''],
['a', '', ''],
['a', 'c', 'd'],
['b', 'c', ''],
['b', 'c', '']]
How do I remove those null values from the list so the output looks like this?
[['a', 'b', 'c'],
['b'],
['a'],
['a', 'c', 'd'],
['b', 'c'],
['b', 'c']]