title: Split multiline string and append to a new list
body: <p>I have a csv file which has a set of records. One of the columns is a multiline string. I need to split these lines and duplicate the main list. For example, if the file contains the following records.</p>
  
  <pre><code>Row 1 - John, 2501, Admin/Partner/HR, TX
  Row 2 - Max, 3489, Accountant/Admin/HR, MN
  </code></pre>
  
  <p>where <code>Admin/Partner/HR</code> and <code>Accountant/Admin/HR</code> are multiline strings.
  I need the output as below:</p>
  
  <pre><code>Row 1 - John, 2501, Admin, TX
  Row 2 - John, 2501, Partner, TX
  Row 3 - John, 2501, HR, TX
  Row 4 - Max, 3489, Accountant, MN
  Row 5 - Max, 3489, Admin, MN
  Row 6 - Max, 3489, HR, MN
  </code></pre>
  
  <p>I tried the following function</p>
  
  <pre><code>def splitrows(list_old,col):
    count = 0;
    array_new = []
    for row in list_old:
      splitArray = []
      splitarray = row[col].split('\n\n')
      if(len(splitarray)&gt;0):
        for eachLine in splitarray:
          row[col] = eachLine
          array_new.append(row)
  
  
    return array_new
  </code></pre>
  
  <p>If I use append, only the last row gets repeated. If I use array_new+=row, then each column is split and added to the list but I don't want this to happen.</p>
  
  <p>Thanks in advance!</p>