Skip to content

Instantly share code, notes, and snippets.

@segheysens
Last active December 1, 2015 05:56
Show Gist options
  • Save segheysens/750c0eace7e11b159d30 to your computer and use it in GitHub Desktop.
Save segheysens/750c0eace7e11b159d30 to your computer and use it in GitHub Desktop.
# Library for easier file input
import fileinput
# Open searchRequests.txt for appending
outputFile = open('searchRequests.txt', 'r+',encoding='utf-8', errors='ignore')
# Loop through the files, and run process() on each line of each file f
with fileinput.input(files=('April1OutputUTF.txt', 'April2OutputUTF.txt', \
'April3OutputUTF.txt', 'April4OutputUTF.txt', \
'April5OutputUTF.txt', 'April6OutputUTF.txt', \
'April7OutputUTF.txt', 'April8OutputUTF.txt', \
'June1OutputUTF.txt', 'June2OutputUTF.txt', \
'June3OutputUTF.txt', 'June4OutputUTF.txt', \
'March1OutputUTF.txt', 'March2OutputUTF.txt', \
'March3OutputUTF.txt', 'March4OutputUTF.txt', \
'March5OutputUTF.txt', 'March6OutputUTF.txt', \
'March7OutputUTF.txt', 'March7OutputUTF.txt', \
'May1OutputUTF.txt', 'May2OutputUTF.txt', \
'May3OutputUTF.txt', 'May4OutputUTF.txt' )) as f:
# For each line in the current file 'f'
for line in f:
try:
# If that lines contains a GET request to SearchResults.aspx...
if line.find("GET /SearchResults.aspx") != -1:
# Add it to the output file
outputFile.write(line)
except:
print("Encountered an error")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment