Advertisement
1nikitas

Untitled

Mar 13th, 2022
935
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. from sys import stdin
  2. import xlsxwriter
  3. def diagram():
  4.     prices = [[words.strip().split()[0], int(words.strip().split()[1])] for words in stdin]
  5.     prices = [
  6.         [x[0] for x in prices],
  7.         [x[1] for x in prices]]
  8.     workbook = xlsxwriter.Workbook('res.xlsx')
  9.     worksheet = workbook.add_worksheet()
  10.     worksheet.write_column('A1', prices[0])
  11.     worksheet.write_column('B1', prices[1])
  12.     chart = workbook.add_chart({'type': 'pie'})
  13.     chart.add_series({
  14.         'values': ['Sheet1', 0, 1, len(prices[0]) - 1, 1],
  15.         'categories': ['Sheet1', 0, 0, len(prices[0]) - 1, 0],
  16.         'data_labels': {'percentage': True},
  17.     })
  18.     worksheet.insert_chart('C3', chart)
  19.     workbook.close()
  20. diagram()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement