@vgersh99 thank you so much for the response and your time spent to figure out my problem, the output is looking good there have little modifications and need to be done, BTW this will use as a properties of a file or what we could metadata that will bulk import to alfresco using alfresco-bulk-import.
BEGIN {
qq="\""
}
FNR==1{
for(i=1;i<=NF;i++)
tags=tolower($i)
print "<?xml version=" qq "1.0" qq "encoding=" qq "UTF-8" qq "?>\n<!DOCTYPE properties SYSTEM " qq "http://java.sun.com/dtd/properties.dtd" qq ">"
}
{
print "\t<properties>"
for(i=2;i<=NF;i++)
printf("\t\t<entry key=%scm:%s%s>%s</entry>\n", qq, tags, qq, $i)
print "\t</properties>"
}
Here's the ouput:
<?xml version="1.0"encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="cm:name">Name</entry>
<entry key="cm:birthdate">Birthdate</entry>
<entry key="cm:amount">Amount</entry>
</properties>
<properties>
<entry key="cm:name">Name1</entry>
<entry key="cm:birthdate">01.02.19</entry>
<entry key="cm:amount">1000</entry>
</properties>
<properties>
<entry key="cm:name">Name2</entry>
<entry key="cm:birthdate">01.02.20</entry>
<entry key="cm:amount">1000</entry>
</properties>
<properties>
<entry key="cm:name">Name3</entry>
<entry key="cm:birthdate">01.02.21</entry>
<entry key="cm:amount">1000</entry>
</properties>
My expected output each row from CSV file which the first column with red color is the filename this will look like this:
The first column is the actual filename
File,Name,Birthdate,Amount
File1.xml,Name1,01.02.19,1000
File2.xml,Name2,01.02.20,1000
File3.xml,Name3,01.02.21,1000
File1.xml -- File2.xml and so on . . .
<?xml version="1.0"encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="cm:name">Name1</entry>
<entry key="cm:birthdate">01.02.19</entry>
<entry key="cm:amount">1000</entry>
</properties>
And is possible if there is a 5th,6th,7th,8th and 9th column, remove the cm: so the output of each xml file like this:
<?xml version="1.0"encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="cm:name">Name3</entry>
<entry key="cm:birthdate">01.02.21</entry>
<entry key="cm:amount">1000</entry>
<entry key="separator"></entry>
<entry key="namespace"></entry>
<entry key="parentAssociation"></entry>
<entry key="type"></entry>
<entry key="aspects"></entry>
</properties>
CSV File:
File,Name,birthdate,Amount,separator,namespace,parentAssociation,type,aspects
File1.xml,Name1,01.02.19,1000,,,,
File2.xml,Name2,01.02.20,1000,,,,
File3.xml,Name3,01.02.21,1000,,,,