@@ -0,0 +1,1463 @@
+#this code is to import the news import from DW in MAY 2015 release%0A%0A#!/usr/bin/env python%0A%0Aimport uuid%0Aimport ConfigParser%0Aimport pymongo%0Aimport json%0Aimport requests%0Aimport sys, os%0Afrom os.path import isdir, join%0A%0A%0Aclass ItemWriter:%0A%0A  def __init__(self, source, meta_format):%0A    self.mongo_client = pymongo.MongoClient()%0A    self.db = self.mongo_client%5B'eumssi_db'%5D%0A    self.col = self.db%5B'content_items'%5D%0A    self.source = source%0A    self.format = meta_format%0A%0A  def write_item(self, item):%0A    ''' write item to MongoDB '''%0A    try:%0A      twuid = uuid.uuid4()%0A      print %22inserted: %22, self.col.insert(%7B'_id':uuid.uuid4(),'source':self.source,'meta':%7B'original':item, 'original_format':self.format%7D%7D)%0A    except Exception as e:%0A      print e%0A%0A'''%0AExtract items and insert to DB%0A'''%0Adef readJsonData(_param_data_file, language):    %0A    fi = open (_param_data_file, 'r')  %0A    #parse that file%0A    jsoncontent = fi.read()%0A    itemset = json.loads(jsoncontent)%0A    #get items%0A    print %22Infor: %22, len(itemset), %22 news articles found%22%0A    #write data to mongo db%0A    writer = ItemWriter('DW article','DW-fracking-manual-data')   %0A    i = 0%0A    for item in itemset:%0A        i+=1%0A        print i, %22 item indexed %22%0A        item%5B'inLanguage'%5D = language%0A        writer.write_item(item)%0A%0Aif __name__ == '__main__':%0A  print %22@usage: python %5Bme%5D @data_file @language%22%0A  _param_data_file = sys.argv%5B1%5D%0A  language = sys.argv%5B2%5D%0A  readJsonData(_param_data_file, language)

create python code for import instead of command line for small dw data