title: How do you convert a text file to CSV file while keeping text file format using JS?
body: <p>I am reading in a text file with some data that looks like this:</p>
  
  <pre><code>This is my file
  showing some data
  data1 = 12
  data2 = 156
  </code></pre>
  
  <p>I want to convert this data into a CSV file while keeping the same format of the text file, like this:</p>
  
  <pre><code>This,is,my,file
  showing,some,data
  data1,=,12
  data2,=,156
  </code></pre>
  
  <p>My first attempt was to read the text file into a string. The split that string into an array, splitting it at every ' ' (space) char. However, that doesn't seem to work.</p>
  
  <p>I also attempted to split the string into an array at every 'newline' char but it doesn't seem to work.</p>
  
  <p>Can anyone guide me in the right direction? Or how should I go about doing this?</p>
  
  <p>Thanks</p>