This file contains hidden or 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
| df[['httpCode','header']] = df["header"].str.split(" ", 1, expand=True) |
This file contains hidden or 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
| df[['httpProto','header']] = df["header"].str.split("\" ", 1, expand=True) |
This file contains hidden or 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
| df[['url','header']] = df["header"].str.split(" ", 1, expand=True) | |
| # Remove slash (/) at the start of each URL | |
| df['url'] = df['url'].str.replace('/','',n=1) |
This file contains hidden or 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
| df[['Method','header']] = df["header"].str.split(" ", 1, expand=True) |
This file contains hidden or 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
| df[['Domain','header']] = df["header"].str.split(" \"", 1, expand=True) |
This file contains hidden or 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
| # Split Date & Time | |
| df[['Date_Time', 'header']] = df['header'].str.split("\] ", 1, | |
| expand=True) | |
| df['Date_Time'] = df['Date_Time'].str.replace(':.*', '') | |
| # Convert the Date_Time column from string to datetime format | |
| df['Date'] = pd.to_datetime(df['Date_Time'], errors='coerce', | |
| infer_datetime_format=True) | |
| # Remove Time column, for clarity's sake |
This file contains hidden or 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
| # Split IP addresses | |
| df[['IP','header']] = df["header"].str.split(" - - \[", 1, expand=True) | |
| # Remove slash | |
| df['IP'] = df['IP'].str.replace("Row\(\('","",n=1) |
This file contains hidden or 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
| df.rename(columns={0:'header'}, inplace=True) |
This file contains hidden or 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
| # Note that we convert a list of lists, not just a list. | |
| df = pd.DataFrame.from_records(log_sample) | |
| df.info() |
This file contains hidden or 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
| ## Form elements ## | |
| table_name = 'log_sample' #@param {type:"string"} | |
| SQL_1st_Filter ='ch.loggy' #@param {type:"string"} | |
| SQL_Useragent_Filter = "Googlebot/2.1" #@param ["Googlebot/2.1", "YandexBot", "BingBot", "DuckDuckBot", "Baiduspider"] {allow-input: true} | |
| # Temporary Bigquery table name | |
| table_id = table_name | |
| ## Full SQL query ## |