Last active
August 23, 2022 10:00
-
-
Save tnorthey/d9a98de348f7c140b7e2cb574f2c14b9 to your computer and use it in GitHub Desktop.
Python xyz file reader
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
import numpy as np | |
def read_xyz(self, fname): | |
"""Read a .xyz file""" | |
with open(fname, "r") as xyzfile: | |
xyzheader = int(xyzfile.readline()) | |
comment = xyzfile.readline() | |
xyzmatrix = np.loadtxt(fname, skiprows=2, usecols=[1, 2, 3]) | |
atomarray = np.loadtxt(fname, skiprows=2, dtype=str, usecols=[0]) | |
return xyzheader, comment, atomarray, xyzmatrix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment