Vote count:
0
name;num_tel;num_fixe;id_client;num_comd;email;city;date_liv
gwenael;0998452223;1038431234;50C;12345;gwa@yahoo.fr;London;08/07/2015
judith;0954674487;1045227937;23D;78965;judith@yahoo.fr;Toulouse;11/05/2015
from this csv i generate in output this xml using awk command. I need help for 2 problems. tag name (name;num_tel;num_fixe;id_client;num_comd;email;) are the default value of the csv and city;date_liv had been added by user before they generate the csv and they can add more tag after the default tag. my objective is to output all the optionals tags in my xml , once they had been input in the csv i try to use loop for but i have so many mistakes i need help to do it. I started at position 7 because optional tag start at that place until the end.
NF==1 for (i=7;i<=NF;i++)
{
printf " <option>%s</option>\n"
printf " <val>%s</val>\n"
}
secondly how can i rename a tag for exemple num_tel to cell phone in my awk script ?
<rows>
<C: id_client =50C>
<client>
<identity>
<name> gwenael </name>
<M>
<num_fixe> 0998452223 </num_fixe>
<contact>
<cell phone>1038431234 </cell phone> <!--num_tel--!>
</contact>
<option>city</option>
<value>London </value>
<option>date_liv</option>
<value>08/07/2015</value>
<num_comd> 12345</num_comd>
</M>
</identity>
<date_liv>08/07/2015</date_liv>
<locomotion>car</locomotion>
</client>
</C>
<D: id_client>
<pro>
<identity>
<name> judith </name>
<id_client>23D</id_client>
<option>city</option>
<value>Paris </value>
<option>date_liv</option>
<value>08/05/2015</value>
<num_fixe> 0998452223 </num_fixe>
<company>
<num_fixe>1045227937</num_fixe>
</company>
<num_comd> 12345</num_comd>
</identity>
<date_liv>08/07/2015</date_liv>
<locomotion>car</locomotion>
</pro>
</D>
asked 1 min ago
Awk convert csv to xml optionnal tag and rename tag
Aucun commentaire:
Enregistrer un commentaire