title: How to update rows in a CSV file
body: <p>Hello I'm trying to make a program that updates the values in a csv. The user searches for the ID, and if the ID exists, it gets the new values you want to replace on the row where that ID number is. Here <code>row[0:9]</code> is the length of my ID. </p>
  
  <p>My idea was to scan each row from 0-9 or where my ID number is, and when its found, I will replace the values besides it using the <code>.replace()</code> method. This how i did it:</p>
  
  <pre><code>    def update_thing():
          replace = stud_ID +','+ stud_name +','+ stud_course +','+ stud_year
          empty = []
          with open(fileName, 'r+') as upFile:
              for row in f:
                  if row[0:9] == stud_ID:
                      row=row.replace(row,replace)
                      msg = Label(upd_win, text="Updated Successful", font="fixedsys 12 bold").place(x=3,y=120)
                  if not row[0:9] == getID:
                      empty.append(row)
  
          upFile.close()
          upFile = open(fileName, 'w')
          upFile.writelines(empty)
          upFile.close()  
  </code></pre>
  
  <p>But it's not working, I need ideas on how to get through this.</p>
  
  <p><a href="https://i.stack.imgur.com/N3QaQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/N3QaQ.png" alt="Screenshot"></a></p>