diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-11-02 21:35:09 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-11-02 21:35:09 +0100 |
| commit | 1a5effec286e4753dfdd8e8279abbbdf1ce8e0d2 (patch) | |
| tree | 1136e5231a758b8503785a2be66b558510ea2ea6 /check-counts.py | |
| parent | ec63582b349eaa23a9e22fc160ab3a3d621c4f47 (diff) | |
s2 scripts
Diffstat (limited to 'check-counts.py')
| -rw-r--r-- | check-counts.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/check-counts.py b/check-counts.py new file mode 100644 index 00000000..4fed4494 --- /dev/null +++ b/check-counts.py @@ -0,0 +1,39 @@ +import os +import sys +import csv +from math import ceil +import subprocess +import random + +import click + +@click.command() +def check_counts(): + """Split a CSV into groups.""" + mypath = './datasets/scholar/entries/' + onlyfiles = [f for f in os.listdir(mypath) if os.path.isfile(os.path.join(mypath, f))] + recs = [] + for f in onlyfiles: + with open(os.path.join(mypath, f), 'rb') as f: + reader = csv.reader(f, delimiter='|') + print f + print repr(reader) + lines = list(reader) + rec = lines[0] + recs.append(rec) + + out_fn = './datasets/scholar_entries.csv' + write_csv(out_fn, keys=None, chunk=recs) + +# Write a CSV +def write_csv(fn, keys, chunk): + print(fn) + with open(fn, 'w') as f: + writer = csv.writer(f) + if keys is not None: + writer.writerow(keys) + for row in chunk: + writer.writerow(row) + +if __name__ == '__main__': + check_counts() |
