Guest User

Untitled

a guest
Jan 16th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. # тут дебільний варіант в кінці просто .csv
  2. with open('D:\AQA_Python\Kibana\InconsistencyCrawlers.csv', 'w') as my_result:
  3. my_result.write(
  4. 'Crawler Store Name:' + ',' + 'All Products:' + ',' + 'Error Count:' + ',' + 'Percent %' + '\n')
  5. for hit in hits:
  6. name = hit['key']
  7. my_store.append(name)
  8. error = hit['doc_count']
  9. a = int(hit['doc_count'])
  10. if a < 10:
  11. continue
  12. name_plus_error, digit = get_count_products_for_crawler(name)
  13. perc = calculate_percent(name, name_plus_error, error)
  14. my_result.write(name + ',')
  15. my_result.write(digit + ',')
  16. my_result.write(str(error) + ',')
  17. my_result.write(perc + '\n')
  18.  
  19. # тут використав бібліотеку
  20. with open('D:\AQA_Python\Kibana\InconsistencyCrawlersLib.csv', 'w', newline='') as file:
  21. fieldnames = ['Crawler Store Name', 'All Products', 'Error Count', 'Percent %']
  22. writer = csv.DictWriter(file, fieldnames=fieldnames)
  23. writer.writeheader()
  24. for hit in hits:
  25. name = hit['key']
  26. # my_store.append(name)
  27. error = hit['doc_count']
  28. a = int(hit['doc_count'])
  29. if a < 10:
  30. continue
  31. name_plus_error, digit = get_count_products_for_crawler(name)
  32. perc = calculate_percent(name, name_plus_error, error)
  33. writer.writerow({'Crawler Store Name': name, 'All Products': digit, 'Error Count': str(error),
  34. 'Percent %': perc})
Add Comment
Please, Sign In to add comment