ICIX Interview Question: Using a language of your pref... | Glassdoor

Interview Question

QA Manager/Director Interview South San Francisco, CA

Using a language of your preference, parse a log file for a

  key phrase occurring withing a certain date range and redirect the output to a separate file.

Interview Answer

2 Answers


I used perl. The person told me I didn't have it quite right because I hadn't taken into account that there might be white space around the key phrase

Interview Candidate on Jul 14, 2013

### Python code
### Assuming the file is not very large, but has a variation in date/timestamp

import re

fhandle = open("./data.txt", "r")
data = fhandle.read()

# Date range is 15 through 17
lst = re.findall(".*1[5-7]/Sep/2016:00:05:.*", data)

datelines = "\n".join(lst)

# search for some string like 200 2 23
lines = re.findall(".* 200 2 23", datelines)


Suresh Lokiah on Sep 15, 2017

Add Answers or Comments

To comment on this, Sign In or Sign Up.