title: How to insert new lines in Jupyter notebook by code
body: <p>I have a notebook template, and I'm going to fill it on demand.</p>
  
  <p>Lets say i have to read n pandas dataframes</p>
  
  <p>The notebook template looks something like:</p>
  
  <pre><code>#df_id#
  #df_path#
  </code></pre>
  
  <p>And by the time I'm creating it I want to get something like</p>
  
  <pre><code>#[input_data_id: 1]
  df1 = pd.read_csv('path1')
  
  #df_id#
  #paths#
  </code></pre>
  
  <p>Like copying the tags, filling them with each new parameter and repeating</p>
  
  <p>The problem is that I can't see how to insert a new line by code in a jupyter notebook</p>
  
  <p>I've tried different approaches to avoid that, at this moment this is the one I'm using it:</p>
  
  <pre><code>for id_path in input_list:
      id_aux = id_path[0]
      path_aux = id_path[1]
      os.system("""sed -i "s|#paths#|'{0}', #paths#|" {1} """.format(path_aux,
                        file_path))
      os.system("""sed -i "s|#input_ids#|{0}, #input_ids#|" {1}""".format(id_aux,
                        file_path))
  </code></pre>
  
  <p>This results in something like this:</p>
  
  <pre><code>paths = [
      'path1','path2','path3'
  ]
  </code></pre>
  
  <p>And I can loop over it and read the dfs in another array, so in the end I can deal with it, but I would like it to looks better than now, and to get that I would need to insert new lines into the jupyter notebook cell.</p>
  
  <p>I have been working on it for a few days and nothing works, I'm trying to make it easy, starting by doing my array looks from this</p>
  
  <pre><code>paths = [
      'path1','path2','path3'
  ]
  </code></pre>
  
  <p>to this:</p>
  
  <pre><code>paths = [
      'path1',
      'path2',
      'path3',
  ]
  </code></pre>
  
  <p>And the code is something like this</p>
  
  <pre><code>os.system("""sed -i "s|#paths#|'{0}',\n","    #paths#|" {1} """.format(path_aux_mod,file_path))
  </code></pre>
  
  <p>But it does not work. At this time I don't have any idea about how to deal it, because its not only the sed command (which i've been reading about and im not so confident about insert newlines, but also the jupyter notebook cell format which makes the cells looks like this:</p>
  
  <p>This python code</p>
  
  <pre><code>paths = [
      'path1',
      'path2',
      'path3
  ]
  </code></pre>
  
  <p>In the .ipynb file</p>
  
  <pre><code>"paths = [\n",
  "    'path1',\n",
  "    'path2',\n",
  "    'path3'\n",
  "]\n",
  
  </code></pre>
  
  <p>I'm not sure if I'm even able to 'change' the cell format working with a tag that's inside the cell.</p>