Skip to content

Instantly share code, notes, and snippets.

@jbernhard
Created March 26, 2015 15:06
Show Gist options
  • Save jbernhard/85c22c540bf4afe23d1d to your computer and use it in GitHub Desktop.
Save jbernhard/85c22c540bf4afe23d1d to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
""" Read an array from stdin and write to a numpy file. """
import sys
import numpy as np
def main():
if len(sys.argv) != 2:
print('usage: {} output_file'.format(sys.argv[0]))
exit(1)
filename = sys.argv[1]
arr = np.array([l.split() for l in sys.stdin.buffer],
dtype=float).squeeze()
np.save(filename, arr)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment