Python issue with a csv file (personal project)

Hey, I have recently finished the python 3 course in CodeCademy, Now I have a project ! I’m working with a large csv file changing the data of one row in a csv file, and I did this changes.
Now I want to know how can I write this row into a new csv file as the final output.
Is there any help?
I create the file and its row with csv.DictReader() but I have no idea how to move the modified data from the large one into it.

If I’m understanding correctly, you saved the data as a dictionary and want to create a new df?

Would this be of any help?

Or, you might have to create a function that would iterate through the data to create rows, like this:

 for row in reader:
...         print(row['first_name'], row['last_name'])
...
Eric Idle
John Cleese

>>> print(row)
{'first_name': 'John', 'last_name': 'Cleese'}

 

From this documentation:
https://docs.python.org/3.8/library/csv.html#csv.DictReader

1 Like