Output Format: OBJID RA DEC DERED_U DERED_G DERED_R DERED_I DERED_Z PETROR50_R PETROR90_R FRACDEV_R Q_R Z

Select p.ObjID, p.ra, p.dec,
p.dered_u, p.dered_g, p.dered_r, p.dered_i, p.dered_z,
p.petroR50_r, p.petroR90_r, p.fracDeV_r, p.q_r,
p.Err_u, p.Err_g, p.Err_r, p.Err_i, p.Err_z, p.petroR50Err_r, p.petroR90Err_r, p.qErr_r,
s.z, s.zErr, s.zConf
into mydb.dr3dfracdpetq from  SpecOBJall s, PhotoObjall p
WHERE s.specobjid=p.specobjid
and s.zConf>0.95 and s.zWarning=0
and (p.primtarget & 0x00000040 > 0)
and ((flags & 0x8) = 0) and ((flags & 0x2) = 0) and ((flags & 0x40000) = 0)

# input quantities:
# OBJID,RA,DEC,DERED_U,DERED_G,DERED_R,DERED_I,DERED_Z,PETROR50_R,PETROR90_R,FRACDEV_R,Q_R,ERR_U,ERR_G,ERR_R,ERR_I,ERR_Z,PETROR50ERR_R,PETROR90ERR_R,QERR_R,Z,ZERR,ZCONF
#   1   2  3   4       5       6       7       8       9          10         11        12  13    14    15    16    17    18            19            20     21 22  23
# output quantities:
# OBJID RA DEC DERED_U DERED_G DERED_R DERED_I DERED_Z PETROR50_R PETROR90_R FRACDEV_R Q_R Z

awk -F, '{if(NR==1)printf("%s %s %s %s %s %s %s %s %s %s %s %s %s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$21)}' dr3dfracdpetq_mikhailway.csv
awk -F, '{if(NR!=1)printf("%s %s %s %s %s %s %s %s %s %s %s %s %s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$21)}' dr3dfracdpetq_mikhailway.csv > dr3dfracdpetq.txt
