Created
March 8, 2012 21:47
-
-
Save jzrake/2003676 to your computer and use it in GitHub Desktop.
Tee's program that loads some data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
def load_from_many(pattern): | |
""" | |
Take a pattern and return a numpy array containing the concatenation of all | |
the files matching that pattern. Only the first column and rows after the | |
first are returned, and the data values are offset by the difference between | |
the first and second columns of the first row. | |
""" | |
from numpy import array, loadtxt | |
from glob import glob | |
all_data = [ ] | |
for fname in glob(pattern): | |
data = loadtxt(fname) | |
dt = data[0,1] - data[0,0] | |
all_data += (data[1:,0] - data[0,0]).tolist() | |
return array(all_data) | |
if __name__ == "__main__": | |
load_from_many("data/*.dat") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment