Хорошей задачи использовать itertools.
Прочитайте решение как Свести список пар элементов, порожденных расщеплением с ''
list(chain(*(product(*imap(str.split, e)) for e in data)))
И здесь является демонстрация
>>> from pprint import PrettyPrinter
>>> pp = PrettyPrinter(indent = 4)
>>> data = [('Date', 'Type', 'Product'),
('2013/03/07', 'Electronic', 'TV, Radio, Microwave'),
('2013/03/07', 'leather', 'Gucci Wallet')]
>>> from itertools import izip, imap, product, chain
>>> data = list(chain(*(product(*imap(str.split, e)) for e in data)))
>>> pp.pprint(data)
[ ('Date', 'Type', 'Product'),
('2013/03/07', 'Electronic', 'TV,'),
('2013/03/07', 'Electronic', 'Radio,'),
('2013/03/07', 'Electronic', 'Microwave'),
('2013/03/07', 'leather', 'Gucci'),
('2013/03/07', 'leather', 'Wallet')]
Обновление от OP
data = list(chain(*(product(*imap(str.split(','), e)) for e in refined_data))) , I used this line to flatten my code but it showed this error: "type object argument after * must be a sequence, not generator", the simple split breaks all the words even with space and any special character, please help me
Вариант 1:
>>> from operator import methodcaller
>>> list(chain(*(product(*imap(methodcaller("split", ","), e)) for e in data)))
Вариант 2:
>>> list(chain(*(product(*(s.split(",") for s in e)) for e in data)))
Я попытался вложенными ' для 'петель для решения этой проблемы, но не смог это сделать! :( – MHS