def ReadXyzFile(FileName, Scale=(1.0 / ToAng)):
    Text = open(FileName, 'r').read()
    Lines = Text.splitlines()
    nAtoms = None
    r = (0, (- 1))
    if (len(Lines[0].split()) == 1):
        nAtoms = int(Lines[0].split()[0])
        r = (2, (nAtoms + 2))
    Atoms = []
    Xyz = []
    for Line in Lines:
        ls = Line.split()
        try:
            Atom = ls[0]
            (x, y, z) = (float(ls[1]), float(ls[2]), float(ls[3]))
        except:
            continue
        Atom = (Atom[0].upper() + Atom[1:].lower())
        if (Atom not in ElementNames):
            raise Exception(("while reading '%s': unrecognized element '%s'." % (FileName, Atom)))
        Atoms.append(Atom)
        Xyz.append((x, y, z))
    Xyz = (Scale * array(Xyz).T)
    if 0:
        print(("*read '%s':\n%s" % (FileName, str(FAtomSet(Xyz, Atoms)))))
    return (Xyz, Atoms)
def ReadXyzFile(FileName, Scale=(1.0 / ToAng)):
    Text = open(FileName, 'r').read()
    Lines = Text.splitlines()
    nAtoms = None
    r = (0, (- 1))
    if (len(Lines[0].split()) == 1):
        nAtoms = int(Lines[0].split()[0])
        r = (2, (nAtoms + 2))
    Atoms = []
    Xyz = []
    for Line in Lines:
        ls = Line.split()
        try:
            Atom = ls[0]
            (x, y, z) = (float(ls[1]), float(ls[2]), float(ls[3]))
        except:
            continue
        Atom = (Atom[0].upper() + Atom[1:].lower())
        if (Atom not in ElementNames):
            raise Exception(("while reading '%s': unrecognized element '%s'." % (FileName, Atom)))
        Atoms.append(Atom)
        Xyz.append((x, y, z))
    Xyz = (Scale * array(Xyz).T)
    if 0:
        print(("*read '%s':\n%s" % (FileName, str(FAtomSet(Xyz, Atoms)))))
    return (Xyz, Atoms)