Created
April 22, 2012 16:55
-
-
Save joferkington/2465280 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import numpy as np | |
def process_file(filename, num_cols, delimiter='\t'): | |
def items(infile): | |
for line in infile: | |
for item in line.rstrip().split(delimiter): | |
yield float(item) | |
with open(filename, 'r') as infile: | |
data = np.fromiter(items(infile)) | |
return data.reshape((-1, num_cols)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment