diff options
author | Yann Herklotz <git@yannherklotz.com> | 2019-09-18 19:06:44 +0200 |
---|---|---|
committer | Yann Herklotz <git@yannherklotz.com> | 2019-09-18 19:06:44 +0200 |
commit | 7377b2e83143fc45f83b0abc974aafbf6b6a3dfe (patch) | |
tree | e9560b69f478d788c8dc365c44ddfca41d1d00ad /scripts/scale.py | |
parent | 8d96fd2a541a2602544ced741552ebd17714c67d (diff) | |
download | verismith-7377b2e83143fc45f83b0abc974aafbf6b6a3dfe.tar.gz verismith-7377b2e83143fc45f83b0abc974aafbf6b6a3dfe.zip |
Add more scripts
Diffstat (limited to 'scripts/scale.py')
-rwxr-xr-x | scripts/scale.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/scale.py b/scripts/scale.py new file mode 100755 index 0000000..7dbc155 --- /dev/null +++ b/scripts/scale.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import csv +import sys +import random + +def main(filename, output_file): + with open(filename, "r") as f: + reader = list(csv.reader(f)) + newreader = [] + for row in reader: + try: + if float(row[4]) > 900: + row[4] = "900" + if float(row[3]) > 900: + row[3] = "900" + if random.random() < 0.25: + newreader.append(row) + except: + newreader.append(row) + with open(output_file, "w") as f: + writer = csv.writer(f) + writer.writerows(newreader) + +if __name__ == "__main__": + main(sys.argv[1], sys.argv[2]) |