def row_csv2dict(csv_file):
try:
dict_rows = []
with open(csv_file)as f:
reader = csv.reader(f)
fieldnames = next(reader)
index_length = len(fieldnames)
for line in reader:
data_row = {}
for index in range(0, index_length):
data_row[fieldnames[index]] = line[index]
dict_rows.append(data_row)
return dict_rows
except IOError:
print("The file " + csv_file + " doesn't exist")
csv_file:
user,password
test,test