Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- import json
- import glob
- from elasticsearch import Elasticsearch
- from elasticsearch.helpers import parallel_bulk, bulk
- def get_data():
- with open('ira_tweets_csv_hashed.csv') as f:
- cr = csv.DictReader(f)
- for j, ln in enumerate(cr):
- yield {
- "_index": "ira",
- "_type": "tweet",
- "_id": ln['tweetid'],
- "_source": dict(ln)
- }
- es = Elasticsearch()
- bulk(es, get_data())
Add Comment
Please, Sign In to add comment