1

I have this script, where I intend to update a value in a CSV

I understand that I will write it back to the file to actually effect the changes, but I was expecting to be able to change the value in the row list like below.

However, before and after the change, the row remains the same,

Why would that be?

with open(tasks) as csv_file:
    csv_reader = csv.reader(csv_file, delimiter=',')
    for row in csv_reader:
        row[1] == 'ddd'
        print(row)
1
  • What's the problem you are facing? Commented Jul 14, 2020 at 8:50

2 Answers 2

1

You surely meant:

row[1] = 'ddd'
#     ^^^

Your former expression was a boolean test (==) not an assignment and you did nothing with it (no return value whatsoever).

Sign up to request clarification or add additional context in comments.

Comments

0

I think that you should do like below:

row[1] = 'ddd'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.