title: Python update a file's line content
body: <p>I am comparing 2 csv files and trying to update the delimited line of one of the files if a criteria is met.</p>
  
  <p>In this case i compare the first field of the first file with the 26th field of the second file, if the same value is found i want to update the very end of the string with an "OK" string. No error is shown but the line of the file is not updated, i suppose in the following case i am just updating the var instead of the actual file line but i don't know how to do that.</p>
  
  <p>The simplified code is as follows:</p>
  
  <pre><code>import pandas as pd
  import csv
  
  file1 = 'C:\\Users\\MyName\\Desktop\\Some_Directory\\file1.csv'
  file2 = 'C:\\Users\\MyName\\Desktop\\Some_Directory\\file2.csv'
  
  
  for line in file1:
  
      fields_f1 = line.split(";")
      f1_field1 = fields_f1[0];
  
      for line2 in file2:
          fields_f2 = line2.split(",")
          f2_field26 = fields_f1[25]
  
          if f1_field1 is f2_field26:
              UpdateString = ";OK"
              line = str(line) + UpdateString
  </code></pre>