Skip to content

Instantly share code, notes, and snippets.

@joferkington
Created April 22, 2012 16:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joferkington/2465280 to your computer and use it in GitHub Desktop.
Save joferkington/2465280 to your computer and use it in GitHub Desktop.
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