this is my script its having some problem. I just want to save tree variables a1, a2, a3 using numpy savetxt after vstacking them. Its working well when all the variables (a1, a2, a3) are found in the loop. It getting problems when ether one of them found to be empty. So, how it can be tackled. Any help will be appreciated.
a1, a2, a3 =[], [], [],
for a in xfile_UH:
print(a)
d1=np.genfromtxt(a, dtype=str, delimiter='', usecols=np.arange(0,10))
l=d1[0,5]
l1=d1[0,6]
m=d1[1,4]
n=d1[1,5]
p=d1[1,6]
r=d1[1,8]
q=d1[1,9]
if l=='L':
if m=='0':
if n=='0':
if p=='0':
if q=='0':
print(d1[0,0])
a11, a12, a13, a14, a15=d1[0,6], d1[0,7],d1[0,4], d1[1,8], d1[2,8]
z1=np.hstack([a11, a12, a13, a14, a15])
a1.append(z1)
print(z1)
if l=='L':
if m=='0':
if n=='0':
if p=='0':
if q>'0':
print(d1[0,0])
a11, a12, a13, a14, a15=d1[0,6], d1[0,7],d1[0,4], d1[1,9], d1[2,9]
z2=np.hstack([a11, a12, a13, a14, a15])
a2.append(z2)
if l=='L':
if m=='0':
if n=='0':
if p>'0':
if r>'0':
if q=='0':
print(d1[0,0])
a11, a12, a13, a14, a15=d1[0,6], d1[0,7],d1[0,4], d1[1,8], d1[2,8]
z3=np.hstack([a11, a12, a13, a14, a15])
a3.append(z3)
else:
print('continue')
np.savetxt('output.txt', np.vstack([a1, a2, a3]), fmt='%s', delimiter=',') ` Error I found: raise ValueError('all input arrays must have the same shape')
ValueError: all input arrays must have the same shape
>>>