title: Get data from a endpoint and store it in a csv
body: <p>I want to get data from a endpoint. That stores it in a dataframe and convert it in a csv. It gets the data after each time interval but it keeps replacing the values in same row instead of storing all the values in csv.</p>
  
  <pre class="lang-py prettyprint-override"><code>import requests
  import threading
  import csv
  import json
  interval = 3
  from pandas.io.json import json_normalize
  
  def myPeriodicFunction():
      r=requests.get("https://api.coindesk.com/v1/bpi/currentprice.json").json()
  
      df=json_normalize(r['bpi']['USD'])
  
      df.to_csv('data.csv',sep='\t', header=True)
  
  def startTimer():
      threading.Timer(interval, startTimer).start()
      myPeriodicFunction()
  
  startTimer()
  </code></pre>