# Read a data file into the atoms object in ASE

There isn't that many tutorials on Atomic Simulation Environment on the net and among those I saw, the atoms object is always built explicitly within Python.

What if I have a data file containing the coordinate positions of each element in a particular material: Let's say either a CIF or an XYZ or LAMMPS data file of a 4 x 4 cell of molybdenum disulfide.

How do I read this into the atoms object in ASE?

• Don't have the time to write it up in detail, but here is the documentation to read a file into ASE. You just need to specify the format. If you figure it out from this, you can self answer the question to give an example of how this is done.
– Tyberius
Apr 21 at 4:16
• It's typically very simple: from ase import io; atoms=io.read('abc.xyz'); Apr 21 at 13:25

Reading coordinates from a file is a very simple task with ASE. The following code reads the three different file types into an Atoms object:

from ase import io


ASE can detect certain file formats from the ending, like in the case of .cif and .xyz. For the lammps file the format needs to be set explicitly.

The formats that ASE natively supports are documented here: https://wiki.fysik.dtu.dk/ase/ase/io/io.html

And some format specific options are listed here: https://wiki.fysik.dtu.dk/ase/ase/io/formatoptions.html

If the file contains multiple sets of coordinates index can be used to select a certain one or a selection.

from ase import io