From 07cc18c1df11c9a122d40c4d1551cac723a2de04 Mon Sep 17 00:00:00 2001 From: David Kaufmann Date: Wed, 13 Jan 2016 02:37:53 +0100 Subject: [PATCH] fix srcfeat_power.py --- srcfeat_power.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/srcfeat_power.py b/srcfeat_power.py index a1a31e9..25bc098 100755 --- a/srcfeat_power.py +++ b/srcfeat_power.py @@ -7,7 +7,7 @@ from os.path import exists from argparse import ArgumentParser -def principal_symbols(f_in, feat, sortby, output): +def principal_symbols(f_in, feat, sortby): pkts = dict() with open(f_in, 'r') as f: csv = reader(f, delimiter=',', quotechar='"') @@ -45,7 +45,7 @@ def principal_symbols(f_in, feat, sortby, output): pkts[row[sort_field]][row[feat_field]] += 1 # Calculate multimodality estimation and write to output - csvfile = open(output, 'wb') + csvfile = open("/dev/stdout", 'wb') csvwriter = writer(csvfile, delimiter=',', quotechar='"', quoting=QUOTE_MINIMAL) csvwriter.writerow([sortby, 'Number of packets', @@ -64,11 +64,9 @@ def _main(): parser = ArgumentParser(description="Estimate principal symbols.", epilog='Example: %s --input ' % sys.argv[0] + 'csv_file.csv --feature "Time to live" ' + - '--sort-by \\ "Source" --output test.csv') + '--sort-by \\ "Source"') parser.add_argument("--input", type=str, required=True, help="Input CSV file.") - parser.add_argument("--output", type=str, required=True, - help="Output CSV file.") parser.add_argument("--feature", type=str, required=True, help="Feature to aggregate.") parser.add_argument("--sort-by", type=str, default='Source', @@ -79,11 +77,7 @@ def _main(): sys.stderr.write("ERROR: Input file '%s' " % args.input + "does not exist!\n") sys.exit(2) - if exists(args.output): - sys.stderr.write("ERROR: Output file '%s' " % args.output + - "already exists!\n") - sys.exit(2) - principal_symbols(args.input, args.feature, args.sort_by, args.output) + principal_symbols(args.input, args.feature, args.sort_by) if __name__ == '__main__': -- 2.43.0