-
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from SuperCowPowers/parquet_example_improve
Parquet example improve
- Loading branch information
Showing
2 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Zeek log to CSV file Example""" | ||
import os | ||
import sys | ||
import argparse | ||
|
||
# Local imports | ||
from zat.log_to_dataframe import LogToDataFrame | ||
|
||
|
||
if __name__ == '__main__': | ||
# Example to write CSV file from a zeek log | ||
|
||
# Collect args from the command line | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('zeek_log', type=str, help='Specify the zeek log input file') | ||
parser.add_argument('csv_file', type=str, help='Specify the CSV file to write out') | ||
args, commands = parser.parse_known_args() | ||
|
||
# Check for unknown args | ||
if commands: | ||
print('Unrecognized args: %s' % commands) | ||
sys.exit(1) | ||
|
||
# File may have a tilde in it | ||
if args.zeek_log and args.csv_file: | ||
args.zeek_log = os.path.expanduser(args.zeek_log) | ||
args.csv_file = os.path.expanduser(args.csv_file) | ||
|
||
# Convert to dataframe and write out the CSV file | ||
log_to_df = LogToDataFrame() | ||
zeek_df = log_to_df.create_dataframe(args.zeek_log) | ||
print('Dataframe Created: {:d} rows...'.format(len(zeek_df))) | ||
zeek_df.to_csv(args.csv_file, index=False) | ||
print('Complete: {:s} --> {:s}'.format(args.zeek_log, args.csv_file)) |
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