# How to Import This XYZ format file

Here is the .XYZ format file NP3D.XYZ

Somehow i cannot import this file.It return an error box :- "Cannot Import Data As XYZ Format."

it contains 1000 snapshot of 10 Carbon particles coordinate moving in a box that i have to visualise.

• Is the pastebin ok? Please contemplate @OleksandrR. comment verry well! – user9660 Apr 22 '16 at 17:28
• from the wikipedia page en.wikipedia.org/wiki/XYZ_file_format "There is no formal standard and several variations exist" – george2079 Apr 22 '16 at 17:40
• I'm wondering where do you get the simulation data from? – xslittlegrass Apr 22 '16 at 18:24
• Also, what are the units in that file? If angstroms then those atoms are very close together – Jason B. Apr 22 '16 at 18:56
• I really think you need to find out what units these are in, most of the time the units are angstroms, and that is what MMA assumes. Also, it will try to draw bonds between close atoms, which I don't think you want here at all. Figure out he units, and whether you want bonds and then we can help give a better solution. – Jason B. Apr 23 '16 at 7:53

It does not work because of different data elements, compare

Import["ExampleData/caffeine.xyz"]


with data structure

but change it to:

with

Import["NP3D.xyz"]


you will get:

full data looks like

You can make an animation with these snapshots:

data1 = StringRiffle[#, "\n"] & /@
"String"], #2 =!= "10" &][[All, 3 ;; -1]];

data = ParallelMap[ImportString[#, "XYZ"] &, data1]; // AbsoluteTiming



• is there a way for me to change whole data structure from start until end? @Louis – Nabil Apr 22 '16 at 16:27
• Is this ok? pastebin.com/CPWBAPnj – user9660 Apr 22 '16 at 17:16
• It's not okay to just remove the intermediate lines. There are 1000 different structures recorded in the file; drawing these all on top of each other is not what OP wants. Rather, some Manipulate (or something like that) to step through each structure is what is desired. But, OP should be able to sort this out for themselves IMO. – Oleksandr R. Apr 22 '16 at 17:24
• @OleksandrR., i guess you are right, feel free to edit or answer on your self – user9660 Apr 22 '16 at 17:26
• Thank You @Louis . the new data u give is nice – Nabil Apr 23 '16 at 15:28

This will split the text into chunks and plot them as molecular plots,

imglist = ImportString[ExportString[#, "Table"], "XYZ"] & /@
Partition[
StringSplit[
Import["http://comsics.usm.my/tlyoon/teaching/ZCE111_1516SEM2/\
data/NP3D.xyz", "Text"], "\n"], 12];


But, those carbon atoms sure are close together....

imglist[[405]]


Maybe the units are not angstroms?