Skip to content
Advertisement

Find line via string input and replace specific row in CSV file Python

For an Address Book project, I need to find a specific line in a CSV file via input() IE if a user inputs “Toast” it will find the line with Toast on it, then replace a row on that line such as “Jam” with another input from the user.

Is there a way to do this?

Example:

JavaScript

Should then turn into

JavaScript

Advertisement

Answer

I assume you always want to replace the third element of the lines. So I wrote this accordingly

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement