Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # тут дебільний варіант в кінці просто .csv
- with open('D:\AQA_Python\Kibana\InconsistencyCrawlers.csv', 'w') as my_result:
- my_result.write(
- 'Crawler Store Name:' + ',' + 'All Products:' + ',' + 'Error Count:' + ',' + 'Percent %' + '\n')
- for hit in hits:
- name = hit['key']
- my_store.append(name)
- error = hit['doc_count']
- a = int(hit['doc_count'])
- if a < 10:
- continue
- name_plus_error, digit = get_count_products_for_crawler(name)
- perc = calculate_percent(name, name_plus_error, error)
- my_result.write(name + ',')
- my_result.write(digit + ',')
- my_result.write(str(error) + ',')
- my_result.write(perc + '\n')
- # тут використав бібліотеку
- with open('D:\AQA_Python\Kibana\InconsistencyCrawlersLib.csv', 'w', newline='') as file:
- fieldnames = ['Crawler Store Name', 'All Products', 'Error Count', 'Percent %']
- writer = csv.DictWriter(file, fieldnames=fieldnames)
- writer.writeheader()
- for hit in hits:
- name = hit['key']
- # my_store.append(name)
- error = hit['doc_count']
- a = int(hit['doc_count'])
- if a < 10:
- continue
- name_plus_error, digit = get_count_products_for_crawler(name)
- perc = calculate_percent(name, name_plus_error, error)
- writer.writerow({'Crawler Store Name': name, 'All Products': digit, 'Error Count': str(error),
- 'Percent %': perc})
Add Comment
Please, Sign In to add comment