<div dir="ltr">@Joonas:<div><br></div><div>The previous example was a typo. Please use the below example as a case study. </div><div><br></div><div><div><div style="font-size:12.8000001907349px"><ol style="margin:0px;padding:0px 0px 0px 40px;color:rgb(67,67,67);font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap"><li style="font-size:15.8399991989136px;line-height:23.7600002288818px;margin-left:15px;list-style-type:decimal!important;background-color:transparent!important"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(102,102,0)">{</span><span style="color:rgb(0,136,0)">'D_B'</span><span style="color:rgb(102,102,0)">:</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(102,102,0)">[</span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">],</span></code></li><li style="font-size:15.8399991989136px;line-height:23.7600002288818px;margin-left:15px;list-style-type:decimal!important;background-image:initial;background-color:transparent!important;background-repeat:initial"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'F_Int32'</span><span style="color:rgb(102,102,0)">:</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(102,102,0)">[</span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><span style="font-size:15.8399991989136px;line-height:23.7600002288818px"><li style="margin-left:15px;list-style-type:decimal!important;background-color:transparent!important"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><li style="margin-left:15px;list-style-type:decimal!important;background-image:initial;background-color:transparent!important;background-repeat:initial"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><li style="margin-left:15px;list-style-type:decimal!important;background-color:transparent!important"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><li style="margin-left:15px;list-style-type:decimal!important;background-image:initial;background-color:transparent!important;background-repeat:initial"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li></span><li style="font-size:15.8399991989136px;line-height:23.7600002288818px;margin-left:15px;list-style-type:decimal!important;background-color:transparent!important"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><span style="font-size:15.8399991989136px;line-height:23.7600002288818px"><li style="margin-left:15px;list-style-type:decimal!important;background-image:initial;background-color:transparent!important;background-repeat:initial"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><li style="margin-left:15px;list-style-type:decimal!important;background-color:transparent!important"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><li style="margin-left:15px;list-style-type:decimal!important;background-image:initial;background-color:transparent!important;background-repeat:initial"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><li style="margin-left:15px;list-style-type:decimal!important;background-color:transparent!important"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li></span><li style="font-size:15.8399991989136px;line-height:23.7600002288818px;margin-left:15px;list-style-type:decimal!important;background-image:initial;background-color:transparent!important;background-repeat:initial"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><span style="font-size:15.8399991989136px;line-height:23.7600002288818px"><li style="margin-left:15px;list-style-type:decimal!important;background-color:transparent!important"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><li style="margin-left:15px;list-style-type:decimal!important;background-image:initial;background-color:transparent!important;background-repeat:initial"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><li style="margin-left:15px;list-style-type:decimal!important;background-color:transparent!important"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><li style="margin-left:15px;list-style-type:decimal!important;background-image:initial;background-color:transparent!important;background-repeat:initial"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li></span><li style="font-size:15.8399991989136px;line-height:23.7600002288818px;margin-left:15px;list-style-type:decimal!important;background-color:transparent!important"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><span style="font-size:15.8399991989136px;line-height:23.7600002288818px"><li style="margin-left:15px;list-style-type:decimal!important;background-image:initial;background-color:transparent!important;background-repeat:initial"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><li style="margin-left:15px;list-style-type:decimal!important;background-color:transparent!important"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><li style="margin-left:15px;list-style-type:decimal!important;background-image:initial;background-color:transparent!important;background-repeat:initial"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><li style="margin-left:15px;list-style-type:decimal!important;background-color:transparent!important"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li></span><li style="font-size:15.8399991989136px;line-height:23.7600002288818px;margin-left:15px;list-style-type:decimal!important;background-image:initial;background-color:transparent!important;background-repeat:initial"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><span style="font-size:15.8399991989136px;line-height:23.7600002288818px"><li style="margin-left:15px;list-style-type:decimal!important;background-color:transparent!important"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><li style="margin-left:15px;list-style-type:decimal!important;background-image:initial;background-color:transparent!important;background-repeat:initial"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><li style="margin-left:15px;list-style-type:decimal!important;background-color:transparent!important"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><li style="margin-left:15px;list-style-type:decimal!important;background-image:initial;background-color:transparent!important;background-repeat:initial"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">],</span></code></li></span><li style="font-size:15.8399991989136px;line-height:23.7600002288818px;margin-left:15px;list-style-type:decimal!important;background-color:transparent!important"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'OTF'</span><span style="color:rgb(102,102,0)">:</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span></code></li><li style="font-size:15.8399991989136px;line-height:23.7600002288818px;margin-left:15px;list-style-type:decimal!important;background-image:initial;background-color:transparent!important;background-repeat:initial"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'PBDS_Double'</span><span style="color:rgb(102,102,0)">:</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(102,102,0)">[</span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'0'</span><span style="color:rgb(102,102,0)">],</span></code></li><li style="font-size:15.8399991989136px;line-height:23.7600002288818px;margin-left:15px;list-style-type:decimal!important;background-color:transparent!important"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'SCS_String'</span><span style="color:rgb(102,102,0)">:</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(102,102,0)">[</span><span style="color:rgb(0,136,0)">'1'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'2'</span><span style="color:rgb(102,102,0)">]}</span></code></li><li></li></ol></div></div><div><br></div><div>All of the questions regarding XML I have asked. I have to work within their parameters. The CSV, for example may look like this:</div><div><br></div><div><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,0);background-color:transparent">DLA</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0);background-color:transparent">,</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,0);background-color:transparent">FC</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0);background-color:transparent">,</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,0);background-color:transparent">PC</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0);background-color:transparent">,</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,0);background-color:transparent">WC</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0);background-color:transparent">,</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,0);background-color:transparent">CN</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0);background-color:transparent">,</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,0,102);background-color:transparent">Description</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0);background-color:transparent">,</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,0,102);background-color:transparent">Code</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0);background-color:transparent">,</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,0);background-color:transparent">CMC </span><br><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,102,102);background-color:transparent">0</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0);background-color:transparent">,</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,102,102);background-color:transparent">00000</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0);background-color:transparent">,</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,102,102);background-color:transparent">0</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0);background-color:transparent">,</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,102,102);background-color:transparent">0</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0);background-color:transparent">,,,</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,102,102);background-color:transparent">0</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0);background-color:transparent">,</span><span style="font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,102,102);background-color:transparent">0</span><br></div><div><br></div><div>I have made some head way, as stated previously. I have now been able to experiment with a list comprehension that will demonstrates how each header will need  to be for headers with repeating values. </div><div><br></div><div><ol style="margin:0px;padding:0px 0px 0px 40px;color:rgb(67,67,67);font-family:Consolas,Monaco,'Courier New',Courier,monospace;font-size:15.8400001525879px;line-height:23.7600002288818px;white-space:pre-wrap"><li style="list-style-type:decimal!important;background-color:transparent!important"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(102,102,0)">>>></span><span style="color:rgb(0,0,0)"> key </span><span style="color:rgb(102,102,0)">=</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'spam'</span></code></li><li style="list-style-type:decimal!important;background-image:initial;background-color:transparent!important;background-repeat:initial"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(102,102,0)">>>></span><span style="color:rgb(0,0,0)"> L </span><span style="color:rgb(102,102,0)">=</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(102,102,0)">[</span><span style="color:rgb(0,136,0)">'foo'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'bar'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'baz'</span><span style="color:rgb(102,102,0)">]</span></code></li><li style="list-style-type:decimal!important;background-color:transparent!important"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(102,102,0)">>>></span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(102,102,0)">[(</span><span style="color:rgb(0,136,0)">'{}{}'</span><span style="color:rgb(102,102,0)">.</span><span style="color:rgb(0,0,0)">format</span><span style="color:rgb(102,102,0)">(</span><span style="color:rgb(0,0,0)">key</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> i</span><span style="color:rgb(102,102,0)">),</span><span style="color:rgb(0,0,0)"> value</span><span style="color:rgb(102,102,0)">)</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,0,136)">for</span><span style="color:rgb(0,0,0)"> i</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> value </span><span style="color:rgb(0,0,136)">in</span><span style="color:rgb(0,0,0)"> enumerate</span><span style="color:rgb(102,102,0)">(</span><span style="color:rgb(0,0,0)">L</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,102,102)">1</span><span style="color:rgb(102,102,0)">)]</span></code></li><li style="list-style-type:decimal!important;background-image:initial;background-color:transparent!important;background-repeat:initial"><code style="font-family:Consolas,Monaco,'Courier New',Courier,monospace"><span style="color:rgb(102,102,0)">[(</span><span style="color:rgb(0,136,0)">'spam1'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'foo'</span><span style="color:rgb(102,102,0)">),</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(102,102,0)">(</span><span style="color:rgb(0,136,0)">'spam2'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'bar'</span><span style="color:rgb(102,102,0)">),</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(102,102,0)">(</span><span style="color:rgb(0,136,0)">'spam3'</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,136,0)">'baz'</span><span style="color:rgb(102,102,0)">)]</span></code></li></ol><div><br></div></div><div><br></div><div><font face="verdana, sans-serif" color="#000000"><span style="line-height:23.7600002288818px;white-space:pre-wrap">Is there a way that you know of that will:</span></font></div><div><font face="verdana, sans-serif" color="#000000"><span style="line-height:23.7600002288818px;white-space:pre-wrap"><br></span></font></div><div><font face="verdana, sans-serif" color="#000000"><span style="line-height:23.7600002288818px;white-space:pre-wrap">1) Allow me to preserve the following two functions:</span></font></div><div><font face="verdana, sans-serif" color="#000000"><span style="line-height:23.7600002288818px;white-space:pre-wrap"><br></span></font></div><div><div style="font-size:12.8000001907349px"><div>port json </div><div>import sys </div><div><br></div><div>def hook(obj): </div><div>    return obj </div><div><br></div><div>def flatten(obj): </div><div>    for k, v in obj: </div><div>        if isinstance(v, list): </div><div>            yield from flatten(v) </div><div>        else: </div><div>            yield k, v </div><div><br></div><div>if __name__ == "__main__": </div><div>    with open("somefileneame.json") as f: </div><div>        data = json.load(f, object_pairs_hook=hook) </div><div><br></div><div>    pairs = list(flatten(data)) </div><div><br></div><div>    writer = csv.writer(sys.stdout) </div><div>    header = writer.writerow([k for k, v in pairs]) </div><div>    row = writer.writerow([v for k, v in pairs]) #writer.writerows for any other iterable object</div></div><div style="font-size:12.8000001907349px"><br></div></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">and </div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">2)</div><div style="font-size:12.8000001907349px"><br></div><div><span style="font-size:12.8000001907349px">Will conditionally allow me to recursively check if a key has a nested array. If so, then apply the </span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,0)"> </span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0)">[(</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,136,0)">'{}{}'</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0)">.</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,0)">format</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0)">(</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,0)">key</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0)">,</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,0)"> i</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0)">),</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,0)"> value</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0)">)</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,0)"> </span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,136)">for</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,0)"> i</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0)">,</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,0)"> value </span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,136)">in</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,0)"> enumerate</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0)">(</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,0)">L</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0)">,</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,0,0)"> </span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(0,102,102)">1</span><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap;color:rgb(102,102,0)">)]</span><font color="#000000"><span style="font-size:15.8399991989136px;font-family:Consolas,Monaco,'Courier New',Courier,monospace;line-height:23.7600002288818px;white-space:pre-wrap"> </span><span style="line-height:23.7600002288818px;white-space:pre-wrap"><font face="verdana, sans-serif">list comprehension?</font></span></font></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 19, 2015 at 4:32 PM, Joonas Liik <span dir="ltr"><<a href="mailto:liik.joonas@gmail.com" target="_blank">liik.joonas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">this.. might not throw an eror, but you have 2 keys with the same name<br>
"F", and 1 of them will probably be disgarded..., you have data<br>
corruption even before you try to process it.<br>
<span><br>
{<br>
 "F": "False",<br>
"F": {<br>
"Int32": ["0",<br>
"0",<br>
"0"]<br>
},<br>
 }<br>
<br>
</span>you mentioned Excel at one point.<br>
perhaps you could mock up what you'd like your finished data to look<br>
like in a spreadsheet (google docs for instance, since thats easy to<br>
link to) and reference there.<br>
<br>
just having a list of headers doesnt say much about the data format you want.<br>
<br>
"client wants csv" hmm..they want "csv" or they want "csv that fists<br>
this very particular description that fits our special decoder or the<br>
like" ?<br>
<br>
do you know how the client will use this data. could that info be used<br>
to simplify the output to some degree?<br>
<br>
and finally..<br>
the client gives you malformed xml??<br>
I'm very sorry to hear that. also does the client know they are<br>
emitting invalid xml?<br>
    is it rly xml?<br>
    is it valid in another language? (html is much more lenient for<br>
instance, an html parser might be able to gleam more meaning)<br>
    by what definition is it malformed? is it outright structuralyl<br>
broken, does it fail to meet some schema?<br>
                      does it fail to meet some expectation you have<br>
for some reason ("client said it has these properties")<br>
<br>
you also mentioned you use JSON because it maps nicely to python<br>
dicts.. this is true ofc.. but why not just read that in to a python<br>
dict in the first place?<br>
<span><br>
> DB1 : 0, DB2: 0, DB3: 0 etc. and F1: 0, F1: 0. DB1, DB2 would be the headers and the 0s as values in the CSV file.<br>
<br>
</span>DB1 etc seems ok at first glance however...<br>
say there are 2 nested items and each of them have a DB property which<br>
is an array, you will have name collisions.<br>
you need more thought in to naming the headers at the very least.<br>
<br>
if this is meant for a spreadsheet.. then you will end up with 2 very<br>
very very long rows, it will NOT be readable by any stretch of the<br>
imagination.. do you want this.<br>
<br>
i'm afraid you'll essentially end up with a translation that looks sth like<br>
<br>
{A:{b:"c",q:"w"}}<br>
===============<br>
"A.b", "A.q"<br>
"c", "w"<br>
<br>
if you just want key-value pairs there are better options out<br>
there..besides csv..<br>
</blockquote></div><br></div></div>