
#!/usr/bin/python
from datetime import date
import os
import time
import fileinput
##this function changes the modified date in a txt file
def change_file_modified_date():
    file_list = os.listdir(os.getcwd())
    for filename in file_list:
        if filename.endswith('csv'):
            today= time.strftime('%m/%d/%Y', time.gmtime(os.path.getmtime(filename)))
            file_to_modify = filename.split('.')[0] + '_readme.txt'
            print(file_to_modify)
            text = 'Date last modified:'
            new_text = 'Date last modified:' + today
            #x = fileinput.input(file_to_modify, inplace=1)
           # if x:
            if file_to_modify:
                x = [line.rstrip('\n') for line in open(file_to_modify)]
                for line in x:
                    if text in line:
                        line = new_text
                print line,
            #x.close()
            continue
         
       

if __name__== "__main__":
     change_file_modified_date()






















