diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-02-18 03:04:46 -0500 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-02-18 03:04:46 -0500 |
commit | 89e5192f1ee83ebb3a7bd87aefc5d23ce4ab2c2b (patch) | |
tree | 4cdc41b4750719c13eb8f6534fce879c577dbd88 /util.py | |
parent | e37ed32d9b861581942ec5cfb8948f0602c0a481 (diff) |
Support for compacting binary data
Diffstat (limited to 'util.py')
-rw-r--r-- | util.py | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -8,6 +8,15 @@ def load_csv_file(fname, *args, **kargs): | |||
8 | f.close() # don't leak file handles | 8 | f.close() # don't leak file handles |
9 | return data | 9 | return data |
10 | 10 | ||
11 | def load_csv_file_fast(fname): | ||
12 | data = np.loadtxt(fname, delimiter=",") | ||
13 | return data | ||
14 | |||
15 | def load_binary_file(fname, dtype='float32', modify=False): | ||
16 | data = np.memmap(fname, dtype=dtype, | ||
17 | mode='r+' if modify else 'c') | ||
18 | return data | ||
19 | |||
11 | def write_csv_file(fname, rows, header=None, width=None, | 20 | def write_csv_file(fname, rows, header=None, width=None, |
12 | break_col=None): | 21 | break_col=None): |
13 | if fname is None: | 22 | if fname is None: |