title: Import csv file in cassandra using python script
body: <p>I want to import a csv file in cassandra using python script. I already know how to import csv in cassandra using the COPY command in the cqlsh. </p>
  
  <p>My <a href="https://i.stack.imgur.com/8eIEw.png" rel="nofollow noreferrer">csv file</a> with dtypes: timestamp, timestamp, decimal, decimal, decimal, decimal, decimal, decimal</p>
  
  <p>I already have a code, and I am only lacking on how I would import the csv file inside cassandra</p>
  
  <pre><code>KEYSPACE = "test_cassandra"
  
  cluster = Cluster(['127.0.0.1'])
  session = cluster.connect()
  
  log.info("creating keyspace . . .")
  session.execute("""
      CREATE KEYSPACE IF NOT EXISTS %s 
      WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} 
      """ % KEYSPACE)
  
  log.info("setting keyspace . . .")
  session.set_keyspace(KEYSPACE)
  
  log.info("creating table . . .")
  session.execute("""
      CREATE TABLE IF NOT EXISTS test_NYC_taxi (
          pickup timestamp, 
          dropoff timestamp, 
          distance decimal, 
          fare decimal, 
          p_long decimal, 
          p_lat decimal, 
          d_long decimal, 
          d_lat decimal, 
          PRIMARY KEY(pickup, dropoff, distance));
      """)
  
  
  
  prepared = session.prepare("""
          INSERT INTO test_nyc_taxi (pickup, dropoff, distance, fare, p_long, p_lat, d_long, d_lat)
          VALUES (?, ?, ?, ?, ?, ?, ?, ?)
          """)
  
  
  </code></pre>
  
  <p>Any help would be very much appreciated. :)</p>