Define a function named readDataFromCSVFile with one parameter. The argument passed to the function should be a string which is the name of a CSV file containing data. The file will have a header row and data rows. For example, suppose the file sample.csv contains: apno,value REP-12,450 ELEC-72,2000
The file has a header row: apno,value
After the header row the file has two data rows: REP-12,450 ELEC-72,2000
This function must return a list of dictionaries. Each dictionary must pair a key from the header row with the corresponding value from given data row. For example, readDataFromCSVFile("sample.csv") must return the following dictionary: [{'apno': 'REP-12', 'value': '450'},{'apno': 'ELEC-72', 'value': '2000'}] [not working for large sample of data]1
Aucun commentaire:
Enregistrer un commentaire