Guest User

Untitled

a guest
Oct 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. import csv
  2. import json
  3. import glob
  4. from elasticsearch import Elasticsearch
  5. from elasticsearch.helpers import parallel_bulk, bulk
  6.  
  7. def get_data():
  8. with open('ira_tweets_csv_hashed.csv') as f:
  9. cr = csv.DictReader(f)
  10. for j, ln in enumerate(cr):
  11. yield {
  12. "_index": "ira",
  13. "_type": "tweet",
  14. "_id": ln['tweetid'],
  15. "_source": dict(ln)
  16. }
  17.  
  18. es = Elasticsearch()
  19.  
  20. bulk(es, get_data())
Add Comment
Please, Sign In to add comment