the code:
def import_csv():
with open('list.csv') as csvfile:
reader = csv.DictReader(csvfile,delimiter=",")
print(list(reader))
the Output is:
[OrderedDict([('Anrede', 'asfsf'), ('Vorname', 'dsfsdfsd'), ('Nachname', 'sdfsdfdsf'), ('Strasse', 'sdfsdfsd'), ('Hausnummer', 'sdf'), ('PLZ', 'dsf'), ('Stadt', 'dsf'), ('Telefon1', 'dsf'), ('Telefon2', 'sdf'), ('E-Mail', 'sdf')]), OrderedDict([('Anrede', '123123'), ('Vorname', '213213'), ('Nachname', '213123'), ('Strasse', '123213'), ('Hausnummer', '12312'), ('PLZ', '21323'), ('Stadt', '23'), ('Telefon1', '23'), ('Telefon2', '23'), ('E-Mail', '2')])]
My CSV file looks like:
Anrede,Vorname,Nachname,Strasse,Hausnummer,PLZ,Stadt,Telefon1,Telefon2,E-Mail
asfsf,dsfsdfsd,sdfsdfdsf,sdfsdfsd,sdf,dsf,dsf,dsf,sdf,sdf
123123,213213,213123,123213,12312,21323,23,23,23,2
I can't find a solution, why not my output is the same as at this question: Convert a csv.DictReader object to a list of dictionaries?
I want to read the lines as a dict with the header information as the keys, and then save all this together as a list.