convert csv file to list of dictionaries

前端 未结 6 1363
我寻月下人不归
我寻月下人不归 2020-12-04 19:01

I have a csv file

col1, col2, col3
1, 2, 3
4, 5, 6

I want to create a list of dictionary from this csv.

output as :



        
6条回答
  •  囚心锁ツ
    2020-12-04 19:59

    Another simpler answer:

        import csv
        with open("configure_column_mapping_logic.csv", "r") as f:
            reader = csv.DictReader(f)
            a = list(reader)
            print a
    

提交回复
热议问题