title: Piping data from a python script into a .csv or .txt file
body: <p>I want to monitor air quality inside my flat (downstairs neighbor is an avid smoker). For so doing, I have a Raspberry Pie 3 Model B+ connected with an Enviro+.</p>
  
  <p>While in the terminal I can run the script that measures small particles.
  <code>python particulates.py</code> cf. 
  <a href="https://github.com/pimoroni/enviroplus-python/blob/master/examples/particulates.py" rel="nofollow noreferrer">https://github.com/pimoroni/enviroplus-python/blob/master/examples/particulates.py</a></p>
  
  <p>It then runs and display the data in the terminal, like in the picture below: (yes, I am better at lego-ing, than coding). <img src="https://i.imgur.com/OQoqt15.jpg" alt="Text"></p>
  
  <p>I am interested in keeping a record of the data in a text files or a csv, so I was thinking if there is a way to pipe the data that is shown on the screen directly into a csv or txt files. I know, I could probably write a simple Python script that makes it nice and tight, but I heard many praises of pipping in Linux, that I wanted to give it a try. Moreover, I saw in one forum that: </p>
  
  <blockquote>
    <p><strong>Awk</strong> and <strong>Sed</strong> are your Shell script friends.
    In Linux everything is a file, Awk and Sed can write/edit files.
    Horrible old stuff that comes with every Linux OS and just works.</p>
    
    <p>If you use a webserver then no need for all that x11 desktop bloat stuff, just a headless Linux OS.
    Easy fit all this on a 128MB card.
    Busybox has a webserver or you can pick from a bunch of options.
    I use shell script and Awk/Sed to rewrite the CGI/HTML files on the fly.</p>
  </blockquote>
  
  <p>Source: <a href="https://www.raspberrypi.org/forums/viewtopic.php?t=248733" rel="nofollow noreferrer">https://www.raspberrypi.org/forums/viewtopic.php?t=248733</a></p>
  
  <p>I have typed the following in the terminal:</p>
  
  <pre><code>python Particulates.py &gt; data.csv
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>python Particulates.py | data.csv
  </code></pre>
  
  <p>The data were displayed on the screen, a csv file was created, but the data.csv was empty for both options. If my understanding is correct, I need to put the stdout of the particulates.py into the data.csv. There ought to be something missing in there, because, what I get is far from what this awk/sed advocate was advertising in the forum.</p>
  
  <p>Any clue how I could get this done? and if I were to plot the results shall I use gnuplot ? can I use it in the same line, like in a chain of pipe?</p>
  
  <p>Thank you for your help.</p>