File size: 808 Bytes
f38754b
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from pathlib import Path
import csv,json,hashlib
R=Path(__file__).parent
if __name__=='__main__':
    spec=json.loads((R/'DATASET_MANIFEST.json').read_text());total=0
    for e in spec:
        p=R/e['path'];assert p.is_file() and p.resolve().is_relative_to(R.resolve())
        assert hashlib.sha256(p.read_bytes()).hexdigest()==e['sha256']
        with p.open(newline='',encoding='utf-8-sig') as f:
            rd=csv.reader(f);header=next(rd);data=list(rd)
        assert header==e['columns'] and len(data)==e['rows'] and all(len(r)==len(header) for r in data)
        total+=len(data)
    (R/'VALIDATION.json').write_text(json.dumps({'passed':True,'configurations':len(spec),'rows':total,'check':'byte hashes, headers, rectangular rows; not scientific validity'},indent=2));print('PASS',len(spec),total)