Faking your file:
>>> from io import StringIO
>>> file = StringIO('''first_name,last_name
...: tom,hanks
...: tom,cruise''')
Creating the dict:
>>> data = [(k, []) for k in next(file).strip().split(',')]
>>> for line in file:
...: for i, field in enumerate(line.strip().split(',')):
...: data[i][1].append(field)
...:
>>> data = dict(data)
>>> data
{'first_name': ['tom', 'tom'], 'last_name': ['hanks', 'cruise']}
This is more of a programming exercise than a solution you should use in the real world. It's not robust at all and will fail for all kinds of common cases, such as having quoted fields containing commas in the csv file.
With csv
, for other readers:
>>> import csv
>>> reader = csv.reader(file) # assume fresh StringIO instance
>>> dict(zip(next(reader), zip(*reader)))
{'first_name': ('tom', 'tom'), 'last_name': ('hanks', 'cruise')}
(Use dict(zip(next(reader), map(list, zip(*reader))))
if having lists as values is important.)