title: importing csv file data into influxdb
body: <p>is it possible to push csv file data into influxdb. e.g I had a sensor device which update data every minute to csv file. I need to do some operations on it. 
  I need to push csv file data to influxdb and for that purpose i am writing a python script. 
  I tried to find some examples but couldn't successful to find any. below my python script only had reading csv file code which is simple but no code how to pass this csv to influx db. my csv file and code which i am trying looks like this.</p>
  
  <pre><code>DATE,value
  2017-03-23 11:50:38,16
  2017-03-23 11:50:44,83
  2017-03-23 11:50:50,16
  2017-03-23 11:50:56,70
  2017-03-23 11:51:02,96
  </code></pre>
  
  <p>and the code is </p>
  
  <pre><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(host, 8086, rob, xxxx, sensors_data)
  
  
  def read_data(filename):
      with open(filename) as f:
          reader = f.readlines()[1:]
          for line in reader:
              print line
  
  
  if __name__ == '__main__':
      filename = '/home/rob/myfile.csv'
      a = read_data(filename)
  </code></pre>
  
  <p>I find this link but its different and does not according to my requirements. <a href="http://coendegroot.com/grafana-influxdb-and-python-simple-sample/" rel="nofollow noreferrer">http://coendegroot.com/grafana-influxdb-and-python-simple-sample/</a>
  I can read this csv file and now I need to send csv file data to influx db. but I don't know how to do with python script. I tried to find examples but no success. if someone guide me, I will very grateful. 
  thanx a lot</p>
  
  <p>I change the code according to Pigueiras suggestion and it looks like this </p>
  
  <pre><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(host, 8086, rob, xxxx, sensors_data)
  def read_data():
      with open('file.csv') as f:
          return [x.split(',') for x in f.readlines()[1:]]
  
  a = read_data()
  
  for metric in a:
      influx_metric = [{
          'measurement': 'your_measurement',
          'time': a[0],
          'fields': {
              'value': a[1]
          }
      }]
      db.write_points(influx_metric)
  </code></pre>
  
  <p>I tried this code and it give me following error</p>
  
  <pre><code> 'NameError: name 'your_measurement' is not defined
  </code></pre>
  
  <p>and if i use like like 'measurement': 'your_measurement'. then i got this error. .......</p>
  
  <pre><code>    File "all_flux.py", line 37, in &lt;module&gt;
  db.write_points(influx_metric)
    File "/usr/local/lib/python2.7/dist-packages/influxdb/client.py", line 411, in write_points
  tags=tags, protocol=protocol)
    File "/usr/local/lib/python2.7/dist-packages/influxdb/client.py", line 461, in _write_points
  protocol=protocol
    File "/usr/local/lib/python2.7/dist-packages/influxdb/client.py", line 282, in write
  data = make_lines(data, precision).encode('utf-8')
    File "/usr/local/lib/python2.7/dist-packages/influxdb/line_protocol.py", line 154, in make_lines
  _convert_timestamp(point['time'], precision)
    File "/usr/local/lib/python2.7/dist-packages/influxdb/line_protocol.py", line 40, in _convert_timestamp
  raise ValueError(timestamp)
  ValueError: ['2017-03-23 11:50:38', '16\r\n']
  </code></pre>
  
  <p>the DATE field or columns looks like this '2017-03-23 11:50:38'
  so I use return [x.split(',')....
  and also I ignore first line. but i got this value error</p>