Tomas Gavenciak
10 years ago
2 changed files with 35 additions and 12 deletions
@ -0,0 +1,22 @@ |
|||
from seminar import ovvpfile |
|||
import os |
|||
|
|||
|
|||
def read_all_tables(basedir): |
|||
tables = {} |
|||
for fn in os.listdir(basedir): |
|||
if fn.endswith('.csv'): |
|||
print "Reading %s ..." % (fn, ) |
|||
with open(os.path.join(basedir, fn), 'r') as f: |
|||
o = ovvpfile.parse(f, with_headers=False) |
|||
tables[fn[:-4]] = o.rows |
|||
print " %d lines, columns: %s" % (len(o.rows), ' '.join(o.columns), ) |
|||
return tables |
|||
|
|||
def matchrows(tab, key, val): |
|||
return [r for r in tab if r[key]==val] |
|||
|
|||
def onerow(tab, key, val): |
|||
t = matchrows(tab, key, val) |
|||
assert(len(t) == 1) |
|||
return t[0] |
Loading…
Reference in new issue