Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. from __future__ import print_function
  2.  
  3. import os
  4. import pickle
  5. import importlib
  6. import csv
  7. import tablib
  8.  
  9. def read():
  10. for ls in os.listdir('corpus/rnews'):
  11. if ls.endswith('.pkl'):
  12. f = open('corpus/rnews' + ls, 'rb')
  13. data = pickle.load(f)
  14. for datum in data:
  15. print('time = {}, title = {}'.format(datum['ts'], datum['title']))
  16. f.close()
  17.  
  18. headers = ('time','title')
  19.  
  20. data = [f]
  21. data = tablib.Dataset(*data, headers=headers)
  22. f.write("/corpus/")
  23. writer = csv.writer(f)
  24. if __name__ == '__main__':
  25. _build_csv()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement