Skip to content

Instantly share code, notes, and snippets.

@CognitiveDave
Created March 6, 2022 16:35
Show Gist options
  • Save CognitiveDave/6b569f6106ea6412404f084b0c62025c to your computer and use it in GitHub Desktop.
Save CognitiveDave/6b569f6106ea6412404f084b0c62025c to your computer and use it in GitHub Desktop.
records = []
count = 0
for entry in logLines:
elems = entry.decode('utf-8').split('"')
if(len(elems)) > 1:
count += 1
rec = {
'remote_addr' : elems[0].split(' ')[0],
'remote_user' : elems[0].split(' ')[1],
'time_local' : elems[0].split("[")[1].replace("]","").strip(),
'request': elems[1],
'status': elems[2].split(" ")[1],
'bytesSent': elems[2].split(" ")[2],
'referrer': elems[4],
'agent': elems[5]}
records.append(rec)
import pandas as pd
df = pd.DataFrame(records)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment