title: How do I get python to write a csv file from the output my code?
body: <p>I am incredibly new to python, so I might not have the right terminology...</p>
  
  <p>I've extracted text from a pdf using pdfplumber. That's been saved as a object. The code I used for that is:</p>
  
  <pre><code>with pdfplumber.open('Bell_2014.pdf') as pdf:
      page = pdf.pages[0]
      bell = page.extract_text()
      print(bell)
  </code></pre>
  
  <p>So "bell" is all of the text from the first page of the imported PDF.
  <a href="https://i.stack.imgur.com/enZLe.jpg" rel="nofollow noreferrer">what bell looks like</a> I need to write all of that text as a string to a csv. I tried using:</p>
  
  <pre><code> with open('Bell_2014_ex.csv', 'w', newline='') as f:
      writer = csv.writer(f)
      writer.writerows(bell)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>bell_ex = 'bell_2014_ex.csv'
  
  with open(bell_ex, 'w', newline='') as csvfile:
     file_writer = csv.writer(csvfile,delimiter=',')
     file_writer.writerow(bell)
  </code></pre>
  
  <p>All I keep finding when I search this is how to create a csv with specific characters or numbers, but nothing from an output of an already executed code. For instance, I can get the above code:</p>
  
  <pre><code>bell_ex = 'bell_2014_ex.csv'
  
  with open(bell_ex, 'w', newline='') as csvfile:
     file_writer = csv.writer(csvfile,delimiter=',')
     file_writer.writerow(['bell'])
  </code></pre>
  
  <p>to create a csv that has "bell" in one cell of the csv, but that's as close as I can get.
  I feel like this should be super easy, but I just can't seem to get it to work.
  Any thoughts? 
  Please and thank you for helping my inexperienced self.</p>