def main(argv):
    """Process the JSON data and generate a full report out of it."""
    data = load_data(
        r"C:\Users\kyleh\OneDrive\Education\Coursera\Google IT Automation with Python\Automating Real-World Tasks with Python\Week 3\Resources\Automatically Generate a PDF and send it by Email\car_sales.json"
    )
    summary = process_data(data)
    # new_summary = '<br/>'.join(summary)
    print(summary)

    # TODO: turn this into a PDF report

    report = SimpleDocTemplate(
        r"C:\Users\kyleh\OneDrive\Education\Coursera\Google IT Automation with Python\Automating Real-World Tasks with Python\Week 3\Resources\Automatically Generate a PDF and send it by Email\Car Sales Report.pdf"
    )
    styles = getSampleStyleSheet()

    report_title = Paragraph("Last Months Sales Summary", styles["h1"])

    table_style = [('GRID', (0, 0), (-1, -1), 0.5, colors.black)]
    new_summary = [[x] for x in summary]
    report_table = Table(new_summary, style=table_style, hAlign="LEFT")

    report.build([report_title, report_table])

    # TODO: send the PDF report as an email attachment
    msg = email_generate("*****@*****.**", "*****@*****.**",
                         "Sales summary for last month", new_summary,
                         "/tmp/cars.pdf")
    email_send(msg)
Exemplo n.º 2
0
def main(argv):
    data = load_data("/home/student-04-b36fbde96c4c/car_sales.json")
    summary = process_data(data)
    new_summary = '<br/>'.join(summary)
    print(summary)
    report('/tmp/cars.pdf',"Cars report",new_summary,cars_dict_to_table(data))
    msg = email_generate("*****@*****.**","*****@*****.**","Sales summary for last month", new_summary, "/tmp/cars.pdf")
    email_send(msg)
def main(argv):
    """Process the JSON data and generate a full report out of it."""
    data = load_data("/home/student-00-e0f8d165ca2a/car_sales.json")
    summary = process_data(data)
    new_summary = '<br/>'.join(summary)
    print(summary)
    # TODO: turn this into a PDF report
    report('/tmp/cars.pdf', "Cars report", new_summary, cars_dict_to_table(data))
    # TODO: send the PDF report as an email attachment
    msg = email_generate("*****@*****.**", "<username>@example.com",
                         "Sales summary for last month", new_summary, "/tmp/cars.pdf")
    email_send(msg)
def main(argv):
    """Process the JSON data and generate a full report out of it."""
    data = load_data("car_sales.json")
    summary = process_data(data)
    new_summary = '<br/>'.join(summary)
    print(summary)
    # TODO: turn this into a PDF report
    report('/tmp/cars.pdf', "Cars report", new_summary,
           cars_dict_to_table(data))
    # TODO: send the PDF report as an email attachment
    msg = email_generate("*****@*****.**",
                         "{}@example.com".format(os.environ.get('USER')),
                         "Sales summary for last month", new_summary,
                         "/tmp/cars.pdf")
    email_send(msg)
def main(argv):
    """Process the JSON data and generate a full report out of it."""
    data = load_data("car_sales.json")
    summary = process_data(data)
    new_summary = '\n'.join(summary)
    print(summary)
    # TODO: turn this into a PDF report
    report_gen('/tmp/cars.pdf', "Cars report", new_summary,
               cars_dict_to_table(data))
    # TODO: send the PDF report as an email attachment
    msg = email_gen("*****@*****.**",
                    "*****@*****.**",
                    "Sales summary for last month", new_summary,
                    "/tmp/cars.pdf")
    email_send(msg)
Exemplo n.º 6
0
def main(argv):
    """Process the JSON data and generate a full report out of it."""
    data = load_data("../car_sales.json")
    summary = process_data(data)
    new_summary = '\n'.join(summary)
    print(summary)

    # TODO: turn this into a PDF report
    report('/tmp/cars.pdf', "Cars Report", new_summary,
           cars_dict_to_table(data))

    # TODO: send the PDF report as an email attachment
    message = email_generate('*****@*****.**',
                             '*****@*****.**',
                             'Sales summary for last month', new_summary,
                             '/tmp/cars.pdf')
    email_send(message)
Exemplo n.º 7
0
    "The {} generated the most revenue: ${}".format(
      format_car(data[revenue_key]["car"]), max(revenue)),
    "The {} had the most sales: {}".format(
      format_car(data[quantity_key]["car"]), max(numbersold)),
    "The most popular year was {} with {} sales.".format(
      maxyear, yearsold[maxyear])
  ]

  return "\n".join(summary)

def cars_dict_to_table(car_data):
  """Turns the data in car_data into a list of lists."""
  table_data = [["ID", "Car", "Price", "Total Sales"]]
  for item in car_data:
    table_data.append([item["id"], format_car(item["car"]), item["price"], item["total_sales"]])
  return table_data

def main(argv):
   """Process the JSON data and generate a full report out of it."""
  data = load_data("car_sales.json")
  summary = process_data(data)
  print(summary)
    # TODO: turn this into a PDF report
  report('/tmp/cars.pdf', "Cars report", summary, cars_dict_to_table(data))
    # TODO: send the PDF report as an email attachment
  msg = email_generate("*****@*****.**", "student-03-4a1ed70a68a6@examp$
                         "Sales summary for last month", summary, "/tmp/cars.pd$
  email_send(msg)

if __name__ == "__main__":
  main(sys.argv)