Created
March 14, 2016 23:35
-
-
Save anonymous/06299d9943cc9cc8262d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Only need to compile the regex once, outside the loops | |
orderItem = re.compile("[][A-Z]{2}[0-9]{3,7}[.]") | |
for file in os.listdir('.'): | |
detailsList = [] | |
if file.endswith(".log"): | |
logfile = open(file) # File opens as read only by default | |
for line in logfile: | |
orderItemMatches = orderItem.findall(line) | |
if orderItemMatches: | |
# orderItemMatch = orderItemMatch.translate(None, ".") # Not sure what the translate method does | |
detailsList.append(orderItemMatches[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment