Skip to content

Instantly share code, notes, and snippets.

@sbrodehl
Forked from richardjgowers/read_xvg
Last active February 5, 2017 21:16
Show Gist options
  • Save sbrodehl/12850781a98772065539a777a621a0bd to your computer and use it in GitHub Desktop.
Save sbrodehl/12850781a98772065539a777a621a0bd to your computer and use it in GitHub Desktop.
Read xvg file
import numpy as np
import sys
def read_xvg(fname):
"""Read first two columns of data from xvg file fname
Returns numpy array of data
"""
skip = 0
with open(fname, 'r') as f:
for i, line in enumerate(f):
if not line.startswith(('#', '@')):
skip = i
break
return np.genfromtxt(fname, skip_header=skip, usecols=(0, 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment