I have a CSV file with a list of numbers with gaps in them, like:
0001
0002
0003
0005
0007
etc.
And I have an XML file with nodes with identifiers with a list of numbers without gaps, like:
<?xml version='1.0' encoding='utf-8'?>
<root>
<item>
<unitd>0001</unitd>
<unittitle>description of item 1</unittitle>
</item>
<item>
<unitd>0002</unitd>
<unittitle>description of item 2</unittitle>
</item>
<item>
<unitd>0003</unitd>
<unittitle>description of item 3</unittitle>
</item>
<item>
<unitd>0004</unitd>
<unittitle>description of item 4</unittitle>
</item>
<item>
<unitd>0005</unitd>
<unittitle>description of item 5</unittitle>
</item>
<item>
<unitd>0006</unitd>
<unittitle>description of item 6</unittitle>
</item>
<item>
<unitd>0007</unitd>
<unittitle>description of item 7</unittitle>
</item>
</root> <!-- added by edit -->
I want to add an extra element to the items of the XML file that have identifiers that can be found in the CSV file, like this:
<root>
<item>
<unitd>0001</unitd>
<unittitle>description of item 1</unittitle>
<link>link to extra info on item 1</link>
</item>
<item>
<unitd>0002</unitd>
<unittitle>description of item 2</unittitle>
<link>link to extra info on item 2</link>
</item>
<item>
<unitd>0003</unitd>
<unittitle>description of item 3</unittitle>
<link>link to extra info on item 3</link>
</item>
<item>
<unitd>0004</unitd>
<unittitle>description of item 4</unittitle>
</item>
<item>
<unitd>0005</unitd>
<unittitle>description of item 5</unittitle>
<link>link to extra info on item 5</link>
</item>
<item>
<unitd>0006</unitd>
<unittitle>description of item 6</unittitle>
</item>
<item>
<unitd>0007</unitd>
<unittitle>description of item 7</unittitle>
<link>link to extra info on item 7</link>
</item>
Can I do this using python and how or is there a smarter way to take care of this?