title: Shell script to parse CSV to an XML query?
body: <p>I have a list of citations in a <a href="https://docs.google.com/spreadsheet/pub?key=0Ai_PDCcY5g2JdEpiM2FKLTdxTkNOa1J6dWNyMkVVZkE&amp;single=true&amp;gid=0&amp;output=csv" rel="nofollow noreferrer">csv file</a> that I would like to use to fill out the XML based query form at <a href="http://www.crossref.org/guestquery/" rel="nofollow noreferrer">CrossRef</a></p>
  
  <p>CrossRef provides an XML template (below, with unused fields removed), and I would like to parse the columns of the csv file to fill out repeated fields within the <code>query</code> tag :</p>
  
  <pre><code> &lt;?xml version = "1.0" encoding="UTF-8"?&gt;
  &lt;query_batch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xmlns="http://www.crossref.org/qschema/2.0"
    xsi:schemaLocation="http://www.crossref.org/qschema/2.0 http://www.crossref.org/qschema/crossref_query_input2.0.xsd"&gt;
  &lt;head&gt;
     &lt;email_address&gt;test@crossref.org&lt;/email_address&gt;
     &lt;doi_batch_id&gt;test&lt;/doi_batch_id&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;query enable-multiple-hits="true"
              list-components="false"
              expanded-results="false" key="key"&gt;
      &lt;article_title match="fuzzy"&gt;&lt;/article_title&gt;
      &lt;author search-all-authors="false"&gt;&lt;/author&gt;
      &lt;volume&gt;&lt;/volume&gt;
      &lt;year&gt;&lt;/year&gt;
      &lt;first_page&gt;&lt;/first_page&gt;
      &lt;journal_title&gt;&lt;/journal_title&gt;
    &lt;/query&gt;
  &lt;/body&gt;
  &lt;/query_batch&gt;
  </code></pre>
  
  <p>How can this be done in a shell script?</p>
  
  <p>sample input:</p>
  
  <pre><code>author,year,article_title,journal_title,volume,first_page
  Adler,2006,"Biomass yield and biofuel quality of switchgrass harvested in fall or spring","Agronomy Journal",98,1518
  Alexopolou,2008,"Biomass yields for upland and lowland switchgrass varieties grown in the Mediterranean region","Biomass and Bioenergy",32,926
  Balasko,1984,"Yield and Quality of Switchgrass Grown without Soil Amendments.","Agronomy Journal",76,204
  </code></pre>
  
  <p>desired output:</p>
  
  <pre><code>&lt;?xml version = "1.0" encoding="UTF-8"?&gt;
  &lt;query_batch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xmlns="http://www.crossref.org/qschema/2.0"
    xsi:schemaLocation="http://www.crossref.org/qschema/2.0 http://www.crossref.org/qschema/crossref_query_input2.0.xsd"&gt;
  &lt;head&gt;
     &lt;email_address&gt;test@crossref.org&lt;/email_address&gt;
     &lt;doi_batch_id&gt;test&lt;/doi_batch_id&gt;
  &lt;/head&gt;
  &lt;body&gt;
   &lt;query&gt;
    &lt;author&gt;Adler&lt;/author &gt;
    &lt;year&gt;2006&lt;/year &gt;
    &lt;article_title&gt;Biomass yield and biofuel quality of switchgrass harvested in fall or spring&lt;/article_title &gt;
    &lt;journal_title&gt;Agronomy Journal&lt;/journal_title &gt;
    &lt;volume&gt;98&lt;/volume &gt;
    &lt;first_page&gt;1518&lt;/first_page &gt;
   &lt;/query&gt;
   &lt;query&gt;
    &lt;author&gt;Alexopolou&lt;/author &gt;
    &lt;year&gt;2008&lt;/year &gt;
    &lt;article_title&gt;Biomass yields for upland and lowland switchgrass varieties grown in the Mediterranean region&lt;/article_title &gt;
    &lt;journal_title&gt;Biomass and Bioenergy&lt;/journal_title &gt;
    &lt;volume&gt;32&lt;/volume &gt;
    &lt;first_page&gt;926&lt;/first_page &gt;
   &lt;/query&gt;
   &lt;query&gt;
    &lt;author&gt;Balasko&lt;/author &gt;
    &lt;year&gt;1984&lt;/year &gt;
    &lt;article_title&gt;Yield and Quality of Switchgrass Grown without Soil Amendments.&lt;/article_title &gt;
    &lt;journal_title&gt;Agronomy Journal&lt;/journal_title &gt;
    &lt;volume&gt;76&lt;/volume &gt;
    &lt;first_page&gt;204&lt;/first_page &gt;
   &lt;/query&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Other questions provide some help on doing this in <a href="https://stackoverflow.com/questions/3069661/convert-csv-file-to-xml">C#</a> and <a href="https://stackoverflow.com/q/123/199217">Java</a></p>