title: Python 3.x Long to Wide Dataset using list/dictionary?
body: <p>I have lurked on these forums for many years and always been able to find my answer, but I am stuck on an issue that I can't seem to solve in Python. I have a dataset like the one below (obviously fictitious):</p>
  
  <p>Input:</p>
  
  <pre><code>wound_list =[
  ['1065', '', 'Drew, DonnaLee', '8/22/2018 8:23:00 AM','Wound 1 Length', '2.5']
  ['1065', '', 'Drew, DonnaLee', '8/22/2018 8:23:00 AM', 'Wound 1 depth', '.8']
  ['1065', '', 'Drew, DonnaLee', '8/22/2018 8:23:00 AM', 'Wound 1- wound care performed', 'yes']
  ['1065', '', 'Drew, DonnaLee', '8/22/2018 8:23:00 AM', 'Wound 1 color', 'red']
  
  ['1065', '', 'Drew, DonnaLee', '8/8/2018 11:34:00 AM', 'Wound 1 Length', '1.8']
  ['1065', '', 'Drew, DonnaLee', '8/8/2018 11:34:00 AM', 'Wound 1- wound care performed', 'yes']
  ['1065', '', 'Drew, DonnaLee', '8/8/2018 11:34:00 AM', 'Wound 1 color', 'red']
  
  ['1065', '', 'Drew, DonnaLee', '8/8/2018 11:34:00 AM', 'Wound 2 Length', '3.5']
  ['1065', '', 'Drew, DonnaLee', '8/8/2018 11:34:00 AM', 'Wound 2- wound care performed', 'no']
  ['1065', '', 'Drew, DonnaLee', '8/8/2018 11:34:00 AM', 'Wound 2 color', 'yellow']
  ['1065', '', 'Drew, DonnaLee', '8/8/2018 11:34:00 AM', 'Wound 2 depth', '.7']]
  </code></pre>
  
  <p>And I want to get it into something like what is below so that I can upload it into a SQLite database:<br>
  Output:</p>
  
  <pre><code>Last_Name, First_Name, Date_Time, Wound_Number, Length, depth, width, color, wound_care_performed
  'Drew', 'DonnaLee', 8/22/2018 8:23:00 AM, 1, 2.5, .8, '', 'red', 'yes'
  'Drew', 'DonnaLee', 8/8/2018 11:34:00 AM, 2, 1.8, '', '', 'red', 'yes'
  'Drew', 'DonnaLee', 8/8/2018 11:34:00 AM, 1, 3.5, .7, '', 'yellow', 'no'
  </code></pre>
  
  <p>I am using this code to parse out the variables and try to keep them in order, but it is having trouble with the wound numbers being different with the date staying the same.</p>
  
  <pre><code>ppt = ''
  date = ''
  woundnumber = ''
  length = ''
  width = ''
  depth = ''
  color = ''
  woundcare = ''
  wound_list_improved=[]
  woundnumbercheck = ''
  for i in range(len(wound_list)):
      for j, d in enumerate(wound_list[i][4]):
          if d.isdigit():
              woundnumbercheck = wound_list[i][4][j]
      if date != wound_list[i][3]:
          wound_list_improved.append([ppt, date, woundnumber, length, width, depth, color, woundcare])
          ppt = ''
          date = ''
          woundnumber = ''
          length = ''
          width = ''
          depth = ''
          color = ''
          woundcare = ''
          for j, d in enumerate(wound_list[i][4]):
              if d.isdigit():
                  woundnumber = wound_list[i][4][j]
          if "Length" in wound_list[i][4]:
              length = wound_list[i][5]
      if woundnumbercheck != woundnumber:
          wound_list_improved.append([ppt, date, woundnumber, length, width, depth, color, woundcare])
          ppt = ''
          date = ''
          woundnumber = ''
          length = ''
          width = ''
          depth = ''
          color = ''
          woundcare = ''
          for j, d in enumerate(wound_list[i][4]):
              if d.isdigit():
                  woundnumber = wound_list[i][4][j]
          if "Length" in wound_list[i][4]:
              length = wound_list[i][5]
      else:
          if "Length" in wound_list[i][4]:
              length = wound_list[i][5]
  </code></pre>
  
  <p>I have shortened the code so that I wouldn't eat up a ton of space. But I feel there has to be a better way to dealing with this sort of issue. Perhaps something with a dictionary?</p>
  
  <p>Thanks for the help in advance!</p>