Saturday, 28 September 2013

Python script for get the files_from_directory, using_grep_on_file, on_day_increment


How can I find all files in directory with the extension .txt in python?


http://stackoverflow.com/questions/3964681/find-all-files-in-directory-with-extension-txt-with-python

import glob
import os
#os.chdir("/mydir")
for files in glob.glob("*.txt"):
    print files


python grep on file

for line in open("file_name"):
 if "search_string" in line:
   print line



Python increment day in datetime:
import datetime
today = datetime.datetime.today()
today += datetime.timedelta(days=1)