B
B
botok14032019-08-14 14:22:34
Python
botok1403, 2019-08-14 14:22:34

Python csv find and replace how?

There is a csv file in which the data is located in this way:
userid, data2, data3
1, test, test
2, test, test
What needs to be done:
1. find the id I need in the csv file
2. delete the id, data1, data2 that row

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Developer, 2019-08-14
@samodum

Create a new csv.
In the loop, you read the first csv line by line and look at the id.
If id is not necessary for you, then you write this line to the second file.
Delete the first file.
Rename the second to the name of the first

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question