title: Import csv data into influxdb from python
body: <p>This has almost certainly been asked.</p>
  
  <p>I have <code>timeseries</code> data that looks like this in a <code>.csv</code> file. The data has no heading, but this is what the different fields are: <code>date,time,open,high,low,close,volume,0</code></p>
  
  <pre><code>2017-09-22,21:50:00,131.36,131.415,131.35,131.39,78489,0
  2017-09-22,21:55:00,131.39,131.4,131.37,131.38,95322,0
  2017-09-22,22:00:00,131.38,131.6,131.31,131.39,1212804,0
  </code></pre>
  
  <p>I am attempting to import this data into <code>InfluxDB</code> from <code>python</code>. I see in the documentation that you have to create the <code>json</code> for it line by line, but I am uncertain how this is done:</p>
  
  <p>This is close, but no cigar. Assume I have the string already split and the datetime-timestamp already in the correct format. When I print the json_body below, I get e.g.,</p>
  
  <pre><code>[{'fields': {'Int_value': '1212804', 'Float_value': '131.39'}, 'time': datetime.datetime(2017, 9, 22, 22, 0), 'measurement': 'quote'}]
  </code></pre>
  
  <p>which doesn't seem right - I seem to be getting only one float value. </p>
  
  <p><strong>What is the correct JSON for input to InfluxDB?</strong></p>
  
  <pre class="lang-python prettyprint-override"><code>import datetime
  import random
  import time
  import os
  import csv
  from csv import reader
  import argparse
  from influxdb import client as influxdb
  
  
  db = influxdb.InfluxDBClient("127.0.0.1", 8086, "", "", "stocks")
  
  
  def read_data(filename):
      print filename
      with open(filename) as f:
          lines = f.readlines()[1:]
  
      return lines
  
  if __name__ == '__main__':
      filename = r"jnj.us.csv"
      lines = read_data(filename)
      for rawline in lines:
          line = rawline.split(",")
          d= getPythonDateTimeFromStr(line[0], line[1])
          #EVERYTHING UP TO HERE WORKS. Not sure how to create the json below
          #====================================
          json_body = [
          {
              "measurement": "quote",
              "time": d,
              "fields": {
                  "Float_value": line[2],
                  "Float_value": line[3],
                  "Float_value": line[4],
                  "Float_value": line[5],
                  "Int_value": line[6]
              }
          }
          ]
  
          print json_body
  
          db.write_points(json_body )
  </code></pre>