title: Mapping data from excel with Python
body: <p>I am reading data from an xls spreadsheet with xlrd. First, I gather the index for the column that contains the data that I need (may not always be in the same column in every instance):</p>
  
  <pre><code>amr_list, pssr_list, inservice_list = [], [], []
  for i in range(sh.ncols):
      for j in range(sh.nrows):
          if 'amrprojectnumber' in sh.cell_value(j,i).lower():
              amr_list.append(sh.cell_value(j,i))
          if 'pssrnumber' in sh.cell_value(j,i).lower():
              pssr_list.append(sh.cell_value(j,i))
          if 'inservicedate' in sh.cell_value(j,i).lower():
              inservice_list.append(sh.cell_value(j,i))
  </code></pre>
  
  <p>Now I have three lists, which I need to use for writing data to a new workbook. The values in a row are related. So the index of an item in one list corresponds to the same index of the items in the other lists. </p>
  
  <p>The <code>amr_list</code> has repeating string values. For example:</p>
  
  <pre><code>['4006BA','4006BA','4007AC','4007AC','4007AC']
  </code></pre>
  
  <p>The <code>pssr_list</code> always shares the same value as the <code>amr_list</code> but with additional info:</p>
  
  <pre><code>['4006BA(1)','4006BA(2)','4007AC(1)','4007AC(2)','4007AC(3)']
  </code></pre>
  
  <p>Finally, the <code>inservice_list</code> may or may not contain a variable date (as read from excel):</p>
  
  <pre><code>[40780.0, '', 40749.0, 40764.0, '']
  </code></pre>
  
  <p>This is the result I want from the data:</p>
  
  <pre><code>amr = { '4006BA':[('4006BA(1)',40780.0),('4006BA(2)','')], '4007AC':[('4007AC(1)',40749.0),('4007AC(2)',40764.0),('4007AC(3)','')] }
  </code></pre>
  
  <p>But I am having a hard time figuring out how an easy way to get there. Thanks in advance.</p>