Some scripts for file format conversion
QE use the xsf file format produced by pwi2xsf.sh and pwo2xsf.sh. They can be opened only by Xcrysden. If you need to open your structure with other tools you can convert it to a cif file using the BABEL converter (http://openbabel.org/wiki/Main_Page) the only problem is that they do it wrong... the converter is unable to write the atom elements of the xsf files to the cif file.
Here is a small script that correct the errors of the wrong cif file obtained with BABEL.
#!/usr/bin/python2
#This script use the wrong output obtained from Babel when it tries to convert a xsf file to a cif file and convert it to a correct cif file
#tha can be opened by Material studio
import os
import sys
import math
#function to count number of lines in file
def file_len(fname):
with open(fname,"r") as f:
for i, l in enumerate(f):
pass
return i + 1
f.close
## program start here ##
#EDIT ONLY HERE (below)
name_prefix="ZnFeO2_spinel_001.out2"
filename=name_prefix+".xsf" #correct xsf
filename1=name_prefix+".xsf.cif1" #wrong cif from Babel
output=name_prefix+".xsf.cif" #right cif at the output
#EDIT ONLY HERE (above)
#Step 1 read from xsf the Element names
nmax=file_len(filename)
f0=open(filename,"r")
i=0 #used as line counter
T=0 #used as logical switch
k=0 #used for PRIMVEC
A=[] #store name
while i<nmax:
line=f0.readline().split()
#print line
if 'PRIMVEC' in line:
i=i+1
T=1
elif 'PRIMCOORD' in line:
i=i+1
T=2
elif T==1:
if k==0:
a=float(line[0])
b=a
k=k+1
elif k==1:
k=k+1
elif k==2:
c=float(line[2])
k=k+1
T=0
i=i+1
elif T==2:
numatoms=int(line[0])
T=3
i=i+1
elif T==3:
A.append([line[0]])
i=i+1
else:
i=i+1
f0.close
#Step 2 read the wrong cif file and write the right cif file
f1=open(filename1,"r")
out=open(output,"w")
i=0 #used as line counter
while i<1:
line=f1.readline()
print >> out, line,
if '_atom_site_occupancy' in line:
i=1 #coordinates start here, exit while loop
for i in range(numatoms):
line=f1.readline().split()
print >> out, " "+str(A[i][0])+str(i), A[i][0], line[2], line[3], line[4], line[5]
f1.close
out.close