lcacoffee

script that displays coffees sold by hour at lca2015. Currently it opens a .json file and converts it into a python dict.

It's missing monday data.

sale by hour is: key - the hour (24hr). Value is total paid sales (people who ran out of vouchers). Number in brackets is total number of coffees sold.

Number in brackets - Number not in brackets = amount of coffees sold with vouchers.

Each sale[day].json file contains a json objects. Important keys/values are:

Product : cappuccino/flat white etc...

Tags : These are taged with coffee followed by ; and if its free ;.

count : amount of these coffees sold.

SKU : ? guess its a ID?

Sales ($) : Amount of dollars from selling coffee

Tax ($) : Amount of tax paid from selling the coffee

Revenue : This is Sales + Tax

Costs ($) : Cost to make the coffees.

Revenue ($) : Amount of revenue made from selling the coffee

Margin ($) : Percent of money made from selling coffee.

There are other keys but the value of them is empty. No point dealing with them.

Open up all the sale[day].json files and create a all salesfile. Append all together.

Amount of recenue made for each product.

Create list of all coffees

Reverse Engineer this - Sell coffee rather than looking at sales. count +1 on product count. cost/tax etc goes up.

Add date + time that coffee was sold.

For each count how much cost/tax/revenue.


In [1]:
import json
import os
import pandas
import getpass

In [2]:
theuser = getpass.getuser()

Need to open all the sale[day].json files and append data.


In [3]:
jsonfold = ('/home/' + theuser + '/github/lcacoffee/')
alldata = ('salebyhour.json')
tueda = ('saletues.json')
weda = ('saleweds.json')
thura = ('salethurs.json')
fria = ('salefri.json')
salhr = (jsonfold + alldata)
salajs = ('/home/wcmckee/cofres/salesall.json')

Read rows in pandas only to 12.


In [17]:
fripan = pandas.read_json('/home/wcmckee/github/lcacoffee/salefri.json')

In [29]:
fricvs = fripan.to_csv()

In [30]:
savcsv = open('/home/wcmckee/cofres/saltest.csv', 'w')
savcsv.write(fricvs)
savcsv.close()

In [34]:
pnrdz = pandas.read_csv('/home/wcmckee/cofres/saltest.csv', index_col=7)

In [37]:
pnrdz[0:13]


Out[37]:
Unnamed: 0 Brand Cost ($) Count Discount ($) Margin (%) Outlet Revenue ($) SKU Sales ($) Sales incl. tax ($) Supplier Supplier Code Tags Tax ($) Type
Product
Cappuccino 0 13 13 0 71.24 LCA 32.21738 10001 45.21738 52 coffee 6.78262
Cappuccino FREE 1 0 63 0 0.00 NaN 0.00000 10009 0.00000 0 coffee; free 0.00000
Chai Latte 2 1 1 0 71.24 NaN 2.47826 10003 3.47826 4 coffee 0.52174
Chai Latte FREE 3 0 9 0 0.00 NaN 0.00000 10010 0.00000 0 coffee; free 0.00000
Espresso FREE 4 0 14 0 0.00 NaN 0.00000 10032 0.00000 0 0.00000
Flat White 5 57 57 0 71.24 NaN 141.26082 10000 198.26082 228 coffee 29.73918
Flat White FREE 6 0 249 0 0.00 NaN 0.00000 10011 0.00000 0 coffee; free 0.00000
Hot Chocolate 7 7 7 0 71.24 NaN 17.34782 10005 24.34782 28 coffee 3.65218
Hot Chocolate FREE 8 0 121 0 0.00 NaN 0.00000 10012 0.00000 0 coffee; free 0.00000
Long Black 9 25 25 0 71.24 NaN 61.95650 10006 86.95650 100 coffee 13.04350
Long Black FREE 10 0 62 0 0.00 NaN 0.00000 10014 0.00000 0 coffee; free 0.00000
Mocha 11 13 13 0 71.24 NaN 32.21738 10004 45.21738 52 coffee 6.78262
Mocha FREE 12 0 81 0 0.00 NaN 0.00000 10015 0.00000 0 coffee; free 0.00000

What the hell. This was working the other day. the filza = (lcacoffee folder + each saleday file.json)


In [4]:
lisz = [tueda, weda, thura, fria]
opaz = open('/home/wcmckee/cofres/salesall.json', 'w')

filza = ('/home/' + theuser + '/github/lcacoffee/' + lis)


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-4-65dacff08a9a> in <module>()
      2 opaz = open('/home/wcmckee/cofres/salesall.json', 'w')
      3 
----> 4 filza = ('/home/' + theuser + '/github/lcacoffee/' + lis)

NameError: name 'lis' is not defined

In [16]:
for lis in lisz:
    opaz = open(salajs, 'a')
    print ('/home/' + theuser + '/github/lcacoffee/' + lis)
    opdayz = open(filza, 'r')
    opaz.write(str(opdayz.read()))
    opaz.close()
    opdayz.close()


/home/wcmckee/github/lcacoffee/saletues.json
/home/wcmckee/github/lcacoffee/saleweds.json
/home/wcmckee/github/lcacoffee/salethurs.json
/home/wcmckee/github/lcacoffee/salefri.json

In [17]:
opaz.close()

In [18]:
opzall = open(salajs, 'r')

The daysales appended into the allsales file are in fact lists.

Options include removing the lists and turning it all into one big json object

Appending all the data into one day.

eg: Product: "cappuccino" Count: 450 (total of week).

File needs steriozie removing the \n


In [19]:
opzall.read()


Out[19]:
'[\r\n  {\r\n    "Outlet":"LCA",\r\n    "Product":"Cappuccino",\r\n    "SKU": 10001,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 2,\r\n    "Sales ($)": 6.9565200000,\r\n    "Tax ($)": 1.0434800000,\r\n    "Sales incl. tax ($)": 8.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 2.0000000000,\r\n    "Revenue ($)": 4.9565200000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Cappuccino FREE",\r\n    "SKU": 10009,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 69,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Chai Latte FREE",\r\n    "SKU": 10010,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 15,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Espresso FREE",\r\n    "SKU": 10032,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" ",\r\n    "Supplier Code":" ",\r\n    "Count": 7,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Flat White",\r\n    "SKU": 10000,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 17,\r\n    "Sales ($)": 59.1304200000,\r\n    "Tax ($)": 8.8695800000,\r\n    "Sales incl. tax ($)": 68.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 17.0000000000,\r\n    "Revenue ($)": 42.1304200000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Flat White FREE",\r\n    "SKU": 10011,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 242,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Hot Chocolate",\r\n    "SKU": 10005,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 5,\r\n    "Sales ($)": 17.3913000000,\r\n    "Tax ($)": 2.6087000000,\r\n    "Sales incl. tax ($)": 20.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 5.0000000000,\r\n    "Revenue ($)": 12.3913000000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Hot Chocolate FREE",\r\n    "SKU": 10012,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 68,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Long Black",\r\n    "SKU": 10006,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 6,\r\n    "Sales ($)": 20.8695600000,\r\n    "Tax ($)": 3.1304400000,\r\n    "Sales incl. tax ($)": 24.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 6.0000000000,\r\n    "Revenue ($)": 14.8695600000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Long Black FREE",\r\n    "SKU": 10014,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 73,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Macchiato FREE",\r\n    "SKU": 10030,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" ",\r\n    "Supplier Code":" ",\r\n    "Count": 4,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Mocha",\r\n    "SKU": 10004,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 3,\r\n    "Sales ($)": 10.4347800000,\r\n    "Tax ($)": 1.5652200000,\r\n    "Sales incl. tax ($)": 12.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 3.0000000000,\r\n    "Revenue ($)": 7.4347800000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Mocha FREE",\r\n    "SKU": 10015,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 61,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Total",\r\n    "SKU":null,\r\n    "Brand":"",\r\n    "Supplier":"",\r\n    "Type":"",\r\n    "Tags":"",\r\n    "Supplier Code":"",\r\n    "Count":572.00,\r\n    "Sales ($)": 114.76,\r\n    "Tax ($)": 17.19,\r\n    "Sales incl. tax ($)": 131.95,\r\n    "Discount ($)": 0.00,\r\n    "Cost ($)": 33.00,\r\n    "Revenue ($)": 81.76,\r\n    "Margin (%)": 71.24433\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Grand Total",\r\n    "SKU":null,\r\n    "Brand":"",\r\n    "Supplier":"",\r\n    "Type":"",\r\n    "Tags":"",\r\n    "Supplier Code":"",\r\n    "Count":572.00,\r\n    "Sales ($)": 114.76,\r\n    "Tax ($)": 17.19,\r\n    "Sales incl. tax ($)": 131.95,\r\n    "Discount ($)": 0.00,\r\n    "Cost ($)": 33.00,\r\n    "Revenue ($)": 81.76,\r\n    "Margin (%)": 71.24433\r\n  }\r\n][\r\n  {\r\n    "Outlet":"LCA",\r\n    "Product":"Cappuccino",\r\n    "SKU": 10001,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 2,\r\n    "Sales ($)": 6.9565200000,\r\n    "Tax ($)": 1.0434800000,\r\n    "Sales incl. tax ($)": 8.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 2.0000000000,\r\n    "Revenue ($)": 4.9565200000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Cappuccino FREE",\r\n    "SKU": 10009,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 69,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Chai Latte FREE",\r\n    "SKU": 10010,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 15,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Espresso FREE",\r\n    "SKU": 10032,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" ",\r\n    "Supplier Code":" ",\r\n    "Count": 7,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Flat White",\r\n    "SKU": 10000,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 17,\r\n    "Sales ($)": 59.1304200000,\r\n    "Tax ($)": 8.8695800000,\r\n    "Sales incl. tax ($)": 68.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 17.0000000000,\r\n    "Revenue ($)": 42.1304200000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Flat White FREE",\r\n    "SKU": 10011,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 242,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Hot Chocolate",\r\n    "SKU": 10005,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 5,\r\n    "Sales ($)": 17.3913000000,\r\n    "Tax ($)": 2.6087000000,\r\n    "Sales incl. tax ($)": 20.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 5.0000000000,\r\n    "Revenue ($)": 12.3913000000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Hot Chocolate FREE",\r\n    "SKU": 10012,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 68,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Long Black",\r\n    "SKU": 10006,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 6,\r\n    "Sales ($)": 20.8695600000,\r\n    "Tax ($)": 3.1304400000,\r\n    "Sales incl. tax ($)": 24.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 6.0000000000,\r\n    "Revenue ($)": 14.8695600000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Long Black FREE",\r\n    "SKU": 10014,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 73,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Macchiato FREE",\r\n    "SKU": 10030,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" ",\r\n    "Supplier Code":" ",\r\n    "Count": 4,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Mocha",\r\n    "SKU": 10004,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 3,\r\n    "Sales ($)": 10.4347800000,\r\n    "Tax ($)": 1.5652200000,\r\n    "Sales incl. tax ($)": 12.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 3.0000000000,\r\n    "Revenue ($)": 7.4347800000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Mocha FREE",\r\n    "SKU": 10015,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 61,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Total",\r\n    "SKU":null,\r\n    "Brand":"",\r\n    "Supplier":"",\r\n    "Type":"",\r\n    "Tags":"",\r\n    "Supplier Code":"",\r\n    "Count":572.00,\r\n    "Sales ($)": 114.76,\r\n    "Tax ($)": 17.19,\r\n    "Sales incl. tax ($)": 131.95,\r\n    "Discount ($)": 0.00,\r\n    "Cost ($)": 33.00,\r\n    "Revenue ($)": 81.76,\r\n    "Margin (%)": 71.24433\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Grand Total",\r\n    "SKU":null,\r\n    "Brand":"",\r\n    "Supplier":"",\r\n    "Type":"",\r\n    "Tags":"",\r\n    "Supplier Code":"",\r\n    "Count":572.00,\r\n    "Sales ($)": 114.76,\r\n    "Tax ($)": 17.19,\r\n    "Sales incl. tax ($)": 131.95,\r\n    "Discount ($)": 0.00,\r\n    "Cost ($)": 33.00,\r\n    "Revenue ($)": 81.76,\r\n    "Margin (%)": 71.24433\r\n  }\r\n][\r\n  {\r\n    "Outlet":"LCA",\r\n    "Product":"Cappuccino",\r\n    "SKU": 10001,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 2,\r\n    "Sales ($)": 6.9565200000,\r\n    "Tax ($)": 1.0434800000,\r\n    "Sales incl. tax ($)": 8.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 2.0000000000,\r\n    "Revenue ($)": 4.9565200000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Cappuccino FREE",\r\n    "SKU": 10009,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 69,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Chai Latte FREE",\r\n    "SKU": 10010,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 15,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Espresso FREE",\r\n    "SKU": 10032,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" ",\r\n    "Supplier Code":" ",\r\n    "Count": 7,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Flat White",\r\n    "SKU": 10000,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 17,\r\n    "Sales ($)": 59.1304200000,\r\n    "Tax ($)": 8.8695800000,\r\n    "Sales incl. tax ($)": 68.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 17.0000000000,\r\n    "Revenue ($)": 42.1304200000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Flat White FREE",\r\n    "SKU": 10011,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 242,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Hot Chocolate",\r\n    "SKU": 10005,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 5,\r\n    "Sales ($)": 17.3913000000,\r\n    "Tax ($)": 2.6087000000,\r\n    "Sales incl. tax ($)": 20.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 5.0000000000,\r\n    "Revenue ($)": 12.3913000000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Hot Chocolate FREE",\r\n    "SKU": 10012,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 68,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Long Black",\r\n    "SKU": 10006,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 6,\r\n    "Sales ($)": 20.8695600000,\r\n    "Tax ($)": 3.1304400000,\r\n    "Sales incl. tax ($)": 24.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 6.0000000000,\r\n    "Revenue ($)": 14.8695600000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Long Black FREE",\r\n    "SKU": 10014,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 73,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Macchiato FREE",\r\n    "SKU": 10030,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" ",\r\n    "Supplier Code":" ",\r\n    "Count": 4,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Mocha",\r\n    "SKU": 10004,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 3,\r\n    "Sales ($)": 10.4347800000,\r\n    "Tax ($)": 1.5652200000,\r\n    "Sales incl. tax ($)": 12.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 3.0000000000,\r\n    "Revenue ($)": 7.4347800000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Mocha FREE",\r\n    "SKU": 10015,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 61,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Total",\r\n    "SKU":null,\r\n    "Brand":"",\r\n    "Supplier":"",\r\n    "Type":"",\r\n    "Tags":"",\r\n    "Supplier Code":"",\r\n    "Count":572.00,\r\n    "Sales ($)": 114.76,\r\n    "Tax ($)": 17.19,\r\n    "Sales incl. tax ($)": 131.95,\r\n    "Discount ($)": 0.00,\r\n    "Cost ($)": 33.00,\r\n    "Revenue ($)": 81.76,\r\n    "Margin (%)": 71.24433\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Grand Total",\r\n    "SKU":null,\r\n    "Brand":"",\r\n    "Supplier":"",\r\n    "Type":"",\r\n    "Tags":"",\r\n    "Supplier Code":"",\r\n    "Count":572.00,\r\n    "Sales ($)": 114.76,\r\n    "Tax ($)": 17.19,\r\n    "Sales incl. tax ($)": 131.95,\r\n    "Discount ($)": 0.00,\r\n    "Cost ($)": 33.00,\r\n    "Revenue ($)": 81.76,\r\n    "Margin (%)": 71.24433\r\n  }\r\n][\r\n  {\r\n    "Outlet":"LCA",\r\n    "Product":"Cappuccino",\r\n    "SKU": 10001,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 2,\r\n    "Sales ($)": 6.9565200000,\r\n    "Tax ($)": 1.0434800000,\r\n    "Sales incl. tax ($)": 8.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 2.0000000000,\r\n    "Revenue ($)": 4.9565200000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Cappuccino FREE",\r\n    "SKU": 10009,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 69,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Chai Latte FREE",\r\n    "SKU": 10010,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 15,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Espresso FREE",\r\n    "SKU": 10032,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" ",\r\n    "Supplier Code":" ",\r\n    "Count": 7,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Flat White",\r\n    "SKU": 10000,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 17,\r\n    "Sales ($)": 59.1304200000,\r\n    "Tax ($)": 8.8695800000,\r\n    "Sales incl. tax ($)": 68.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 17.0000000000,\r\n    "Revenue ($)": 42.1304200000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Flat White FREE",\r\n    "SKU": 10011,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 242,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Hot Chocolate",\r\n    "SKU": 10005,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 5,\r\n    "Sales ($)": 17.3913000000,\r\n    "Tax ($)": 2.6087000000,\r\n    "Sales incl. tax ($)": 20.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 5.0000000000,\r\n    "Revenue ($)": 12.3913000000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Hot Chocolate FREE",\r\n    "SKU": 10012,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 68,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Long Black",\r\n    "SKU": 10006,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 6,\r\n    "Sales ($)": 20.8695600000,\r\n    "Tax ($)": 3.1304400000,\r\n    "Sales incl. tax ($)": 24.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 6.0000000000,\r\n    "Revenue ($)": 14.8695600000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Long Black FREE",\r\n    "SKU": 10014,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 73,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Macchiato FREE",\r\n    "SKU": 10030,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" ",\r\n    "Supplier Code":" ",\r\n    "Count": 4,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Mocha",\r\n    "SKU": 10004,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee",\r\n    "Supplier Code":" ",\r\n    "Count": 3,\r\n    "Sales ($)": 10.4347800000,\r\n    "Tax ($)": 1.5652200000,\r\n    "Sales incl. tax ($)": 12.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 3.0000000000,\r\n    "Revenue ($)": 7.4347800000,\r\n    "Margin (%)": 71.24\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Mocha FREE",\r\n    "SKU": 10015,\r\n    "Brand":" ",\r\n    "Supplier":" ",\r\n    "Type":" ",\r\n    "Tags":" coffee; free",\r\n    "Supplier Code":" ",\r\n    "Count": 61,\r\n    "Sales ($)": 0.0000000000,\r\n    "Tax ($)": 0.0000000000,\r\n    "Sales incl. tax ($)": 0.00,\r\n    "Discount ($)": 0,\r\n    "Cost ($)": 0.0000000000,\r\n    "Revenue ($)": 0.0000000000,\r\n    "Margin (%)": 0.00\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Total",\r\n    "SKU":null,\r\n    "Brand":"",\r\n    "Supplier":"",\r\n    "Type":"",\r\n    "Tags":"",\r\n    "Supplier Code":"",\r\n    "Count":572.00,\r\n    "Sales ($)": 114.76,\r\n    "Tax ($)": 17.19,\r\n    "Sales incl. tax ($)": 131.95,\r\n    "Discount ($)": 0.00,\r\n    "Cost ($)": 33.00,\r\n    "Revenue ($)": 81.76,\r\n    "Margin (%)": 71.24433\r\n  },\r\n  {\r\n    "Outlet":"",\r\n    "Product":"Grand Total",\r\n    "SKU":null,\r\n    "Brand":"",\r\n    "Supplier":"",\r\n    "Type":"",\r\n    "Tags":"",\r\n    "Supplier Code":"",\r\n    "Count":572.00,\r\n    "Sales ($)": 114.76,\r\n    "Tax ($)": 17.19,\r\n    "Sales incl. tax ($)": 131.95,\r\n    "Discount ($)": 0.00,\r\n    "Cost ($)": 33.00,\r\n    "Revenue ($)": 81.76,\r\n    "Margin (%)": 71.24433\r\n  }\r\n]'

In [20]:
opcvs = open(salhr, 'r')

In [21]:
opzrd = opcvs.read()

In [22]:
jdunp = json.loads(opzrd)

In [23]:
valia = []

In [24]:
#pandas.read_json(jdunp)

In [25]:
jdunp.count(int)


Out[25]:
0

In [26]:
len(jdunp)


Out[26]:
6

ok if i cycle through jdunp between 0 and 23 i get the results.

cycle through ints but as a string. must add ' '

Break down coffee sales by hour.

Ignore/delete hours with zero sales. Need to create new dict with this data.

How would it look?


In [27]:
for numtwn in range(0,24):
    print "'" + str(numtwn) + "'"


'0'
'1'
'2'
'3'
'4'
'5'
'6'
'7'
'8'
'9'
'10'
'11'
'12'
'13'
'14'
'15'
'16'
'17'
'18'
'19'
'20'
'21'
'22'
'23'

In [28]:
for jdr in jdunp:
    print jdr['0']


- -
- -
- -
- -
- -
- -

In [29]:
for numtwn in range(0,24):
        print "'" + str(numtwn) + "'"


'0'
'1'
'2'
'3'
'4'
'5'
'6'
'7'
'8'
'9'
'10'
'11'
'12'
'13'
'14'
'15'
'16'
'17'
'18'
'19'
'20'
'21'
'22'
'23'

In [30]:
for dej in jdunp:
    print dej.values()
    valia.append(dej.values())


[u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u' 11 Jan 2015', u'', u'Sun', u'- -', u'- -', u'- -', u'4 (1)', u'0 (9)', u'12 (30)', u'0 (3)', u'8 (9)', u'- -', u'- -']
[u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'8 (9)', u'- -', u'40 (31)', u'44 (123)', u' 12 Jan 2015', u'', u'Mon', u'4 (13)', u'20 (118)', u'8 (52)', u'12 (34)', u'12 (46)', u'4 (33)', u'- -', u'0 (1)', u'- -', u'- -']
[u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'4 (17)', u'- -', u'0 (23)', u'24 (109)', u' 13 Jan 2015', u'', u'Tue', u'8 (25)', u'32 (101)', u'12 (55)', u'16 (43)', u'20 (100)', u'12 (43)', u'- -', u'4 (3)', u'- -', u'- -']
[u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'4 (19)', u'- -', u'8 (24)', u'20 (132)', u' 14 Jan 2015', u'', u'Wed', u'12 (39)', u'32 (133)', u'56 (64)', u'16 (36)', u'52 (83)', u'44 (38)', u'- -', u'- -', u'- -', u'- -']
[u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'8 (20)', u'- -', u'20 (25)', u'68 (115)', u' 15 Jan 2015', u'', u'Thu', u'40 (40)', u'132 (136)', u'52 (55)', u'36 (50)', u'72 (103)', u'32 (49)', u'- -', u'4 (6)', u'- -', u'- -']
[u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'12 (21)', u'- -', u'8 (15)', u'104 (128)', u' 16 Jan 2015', u'', u'Fri', u'28 (41)', u'112 (131)', u'40 (76)', u'40 (54)', u'92 (102)', u'28 (64)', u'- -', u'- -', u'- -', u'- -']

In [30]:


In [31]:
dezrand = len(valia)

In [32]:
azlis = []

In [33]:
for vals in valia:    
    print vals
    azlis.append(vals)


[u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u' 11 Jan 2015', u'', u'Sun', u'- -', u'- -', u'- -', u'4 (1)', u'0 (9)', u'12 (30)', u'0 (3)', u'8 (9)', u'- -', u'- -']
[u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'8 (9)', u'- -', u'40 (31)', u'44 (123)', u' 12 Jan 2015', u'', u'Mon', u'4 (13)', u'20 (118)', u'8 (52)', u'12 (34)', u'12 (46)', u'4 (33)', u'- -', u'0 (1)', u'- -', u'- -']
[u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'4 (17)', u'- -', u'0 (23)', u'24 (109)', u' 13 Jan 2015', u'', u'Tue', u'8 (25)', u'32 (101)', u'12 (55)', u'16 (43)', u'20 (100)', u'12 (43)', u'- -', u'4 (3)', u'- -', u'- -']
[u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'4 (19)', u'- -', u'8 (24)', u'20 (132)', u' 14 Jan 2015', u'', u'Wed', u'12 (39)', u'32 (133)', u'56 (64)', u'16 (36)', u'52 (83)', u'44 (38)', u'- -', u'- -', u'- -', u'- -']
[u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'8 (20)', u'- -', u'20 (25)', u'68 (115)', u' 15 Jan 2015', u'', u'Thu', u'40 (40)', u'132 (136)', u'52 (55)', u'36 (50)', u'72 (103)', u'32 (49)', u'- -', u'4 (6)', u'- -', u'- -']
[u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'- -', u'12 (21)', u'- -', u'8 (15)', u'104 (128)', u' 16 Jan 2015', u'', u'Fri', u'28 (41)', u'112 (131)', u'40 (76)', u'40 (54)', u'92 (102)', u'28 (64)', u'- -', u'- -', u'- -', u'- -']

I need to filter the - - from the results. I really only need the values that have numbers.

Take number in brackets away from number not in brackets. The number in brackets is total amount of coffees sold. The number not in brackets is amount of volchers used. The number that I get when i take away is the coffee sold without volchers.

New dict that shows only the times that coffee were sold and the amount of coffgfges that were solf. Maybe that would works.


In [34]:
betra = []

In [35]:
for azl in azlis:
    betra.append(azl)

In [36]:
anoe = []
anez = []

In [37]:
for betr in betra:
    betr.append(anoe)

In [38]:
for deta in betr:
    #print deta
    if '- -' in deta:
        print deta
    else:
        anez.append(deta)


- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -

In [39]:
fdic = []

In [39]:


In [40]:
for resut in anez:
    print resut
    fdic.append(resut)


12 (21)
8 (15)
104 (128)
 16 Jan 2015

Fri
28 (41)
112 (131)
40 (76)
40 (54)
92 (102)
28 (64)
[]

How come it is only adding the wednesday data in the results. It needs to have all the datas.

Needs to take the number in brackets away from the number not in brackets.


In [41]:
fdic


Out[41]:
[u'12 (21)',
 u'8 (15)',
 u'104 (128)',
 u' 16 Jan 2015',
 u'',
 u'Fri',
 u'28 (41)',
 u'112 (131)',
 u'40 (76)',
 u'40 (54)',
 u'92 (102)',
 u'28 (64)',
 []]

In [42]:
optue = open('/home/wcmckee/Downloads/saletues.json', 'r')

In [43]:
rdtue = optue.read()

In [44]:
tuejs = json.loads(rdtue)

In [45]:
tuejs


Out[45]:
[{u'Brand': u' ',
  u'Cost ($)': 2.0,
  u'Count': 2,
  u'Discount ($)': 0,
  u'Margin (%)': 71.24,
  u'Outlet': u'LCA',
  u'Product': u'Cappuccino',
  u'Revenue ($)': 4.95652,
  u'SKU': 10001,
  u'Sales ($)': 6.95652,
  u'Sales incl. tax ($)': 8.0,
  u'Supplier': u' ',
  u'Supplier Code': u' ',
  u'Tags': u' coffee',
  u'Tax ($)': 1.04348,
  u'Type': u' '},
 {u'Brand': u' ',
  u'Cost ($)': 0.0,
  u'Count': 69,
  u'Discount ($)': 0,
  u'Margin (%)': 0.0,
  u'Outlet': u'',
  u'Product': u'Cappuccino FREE',
  u'Revenue ($)': 0.0,
  u'SKU': 10009,
  u'Sales ($)': 0.0,
  u'Sales incl. tax ($)': 0.0,
  u'Supplier': u' ',
  u'Supplier Code': u' ',
  u'Tags': u' coffee; free',
  u'Tax ($)': 0.0,
  u'Type': u' '},
 {u'Brand': u' ',
  u'Cost ($)': 0.0,
  u'Count': 15,
  u'Discount ($)': 0,
  u'Margin (%)': 0.0,
  u'Outlet': u'',
  u'Product': u'Chai Latte FREE',
  u'Revenue ($)': 0.0,
  u'SKU': 10010,
  u'Sales ($)': 0.0,
  u'Sales incl. tax ($)': 0.0,
  u'Supplier': u' ',
  u'Supplier Code': u' ',
  u'Tags': u' coffee; free',
  u'Tax ($)': 0.0,
  u'Type': u' '},
 {u'Brand': u' ',
  u'Cost ($)': 0.0,
  u'Count': 7,
  u'Discount ($)': 0,
  u'Margin (%)': 0.0,
  u'Outlet': u'',
  u'Product': u'Espresso FREE',
  u'Revenue ($)': 0.0,
  u'SKU': 10032,
  u'Sales ($)': 0.0,
  u'Sales incl. tax ($)': 0.0,
  u'Supplier': u' ',
  u'Supplier Code': u' ',
  u'Tags': u' ',
  u'Tax ($)': 0.0,
  u'Type': u' '},
 {u'Brand': u' ',
  u'Cost ($)': 17.0,
  u'Count': 17,
  u'Discount ($)': 0,
  u'Margin (%)': 71.24,
  u'Outlet': u'',
  u'Product': u'Flat White',
  u'Revenue ($)': 42.13042,
  u'SKU': 10000,
  u'Sales ($)': 59.13042,
  u'Sales incl. tax ($)': 68.0,
  u'Supplier': u' ',
  u'Supplier Code': u' ',
  u'Tags': u' coffee',
  u'Tax ($)': 8.86958,
  u'Type': u' '},
 {u'Brand': u' ',
  u'Cost ($)': 0.0,
  u'Count': 242,
  u'Discount ($)': 0,
  u'Margin (%)': 0.0,
  u'Outlet': u'',
  u'Product': u'Flat White FREE',
  u'Revenue ($)': 0.0,
  u'SKU': 10011,
  u'Sales ($)': 0.0,
  u'Sales incl. tax ($)': 0.0,
  u'Supplier': u' ',
  u'Supplier Code': u' ',
  u'Tags': u' coffee; free',
  u'Tax ($)': 0.0,
  u'Type': u' '},
 {u'Brand': u' ',
  u'Cost ($)': 5.0,
  u'Count': 5,
  u'Discount ($)': 0,
  u'Margin (%)': 71.24,
  u'Outlet': u'',
  u'Product': u'Hot Chocolate',
  u'Revenue ($)': 12.3913,
  u'SKU': 10005,
  u'Sales ($)': 17.3913,
  u'Sales incl. tax ($)': 20.0,
  u'Supplier': u' ',
  u'Supplier Code': u' ',
  u'Tags': u' coffee',
  u'Tax ($)': 2.6087,
  u'Type': u' '},
 {u'Brand': u' ',
  u'Cost ($)': 0.0,
  u'Count': 68,
  u'Discount ($)': 0,
  u'Margin (%)': 0.0,
  u'Outlet': u'',
  u'Product': u'Hot Chocolate FREE',
  u'Revenue ($)': 0.0,
  u'SKU': 10012,
  u'Sales ($)': 0.0,
  u'Sales incl. tax ($)': 0.0,
  u'Supplier': u' ',
  u'Supplier Code': u' ',
  u'Tags': u' coffee; free',
  u'Tax ($)': 0.0,
  u'Type': u' '},
 {u'Brand': u' ',
  u'Cost ($)': 6.0,
  u'Count': 6,
  u'Discount ($)': 0,
  u'Margin (%)': 71.24,
  u'Outlet': u'',
  u'Product': u'Long Black',
  u'Revenue ($)': 14.86956,
  u'SKU': 10006,
  u'Sales ($)': 20.86956,
  u'Sales incl. tax ($)': 24.0,
  u'Supplier': u' ',
  u'Supplier Code': u' ',
  u'Tags': u' coffee',
  u'Tax ($)': 3.13044,
  u'Type': u' '},
 {u'Brand': u' ',
  u'Cost ($)': 0.0,
  u'Count': 73,
  u'Discount ($)': 0,
  u'Margin (%)': 0.0,
  u'Outlet': u'',
  u'Product': u'Long Black FREE',
  u'Revenue ($)': 0.0,
  u'SKU': 10014,
  u'Sales ($)': 0.0,
  u'Sales incl. tax ($)': 0.0,
  u'Supplier': u' ',
  u'Supplier Code': u' ',
  u'Tags': u' coffee; free',
  u'Tax ($)': 0.0,
  u'Type': u' '},
 {u'Brand': u' ',
  u'Cost ($)': 0.0,
  u'Count': 4,
  u'Discount ($)': 0,
  u'Margin (%)': 0.0,
  u'Outlet': u'',
  u'Product': u'Macchiato FREE',
  u'Revenue ($)': 0.0,
  u'SKU': 10030,
  u'Sales ($)': 0.0,
  u'Sales incl. tax ($)': 0.0,
  u'Supplier': u' ',
  u'Supplier Code': u' ',
  u'Tags': u' ',
  u'Tax ($)': 0.0,
  u'Type': u' '},
 {u'Brand': u' ',
  u'Cost ($)': 3.0,
  u'Count': 3,
  u'Discount ($)': 0,
  u'Margin (%)': 71.24,
  u'Outlet': u'',
  u'Product': u'Mocha',
  u'Revenue ($)': 7.43478,
  u'SKU': 10004,
  u'Sales ($)': 10.43478,
  u'Sales incl. tax ($)': 12.0,
  u'Supplier': u' ',
  u'Supplier Code': u' ',
  u'Tags': u' coffee',
  u'Tax ($)': 1.56522,
  u'Type': u' '},
 {u'Brand': u' ',
  u'Cost ($)': 0.0,
  u'Count': 61,
  u'Discount ($)': 0,
  u'Margin (%)': 0.0,
  u'Outlet': u'',
  u'Product': u'Mocha FREE',
  u'Revenue ($)': 0.0,
  u'SKU': 10015,
  u'Sales ($)': 0.0,
  u'Sales incl. tax ($)': 0.0,
  u'Supplier': u' ',
  u'Supplier Code': u' ',
  u'Tags': u' coffee; free',
  u'Tax ($)': 0.0,
  u'Type': u' '},
 {u'Brand': u'',
  u'Cost ($)': 33.0,
  u'Count': 572.0,
  u'Discount ($)': 0.0,
  u'Margin (%)': 71.24433,
  u'Outlet': u'',
  u'Product': u'Total',
  u'Revenue ($)': 81.76,
  u'SKU': None,
  u'Sales ($)': 114.76,
  u'Sales incl. tax ($)': 131.95,
  u'Supplier': u'',
  u'Supplier Code': u'',
  u'Tags': u'',
  u'Tax ($)': 17.19,
  u'Type': u''},
 {u'Brand': u'',
  u'Cost ($)': 33.0,
  u'Count': 572.0,
  u'Discount ($)': 0.0,
  u'Margin (%)': 71.24433,
  u'Outlet': u'',
  u'Product': u'Grand Total',
  u'Revenue ($)': 81.76,
  u'SKU': None,
  u'Sales ($)': 114.76,
  u'Sales incl. tax ($)': 131.95,
  u'Supplier': u'',
  u'Supplier Code': u'',
  u'Tags': u'',
  u'Tax ($)': 17.19,
  u'Type': u''}]

json total and grandt total are useless. remove this so it doesn't muck up when I add everything together. Don't want to manualy remove the files. Maybe edit the files with a script to remove the total and grand total.

Checked the json for grand total and total and removes them if they are there.

Search through the json


In [46]:
saltax = []
salcoun = []

In [47]:
for bran in tuejs:
    #print bran['Revenue ($)']
    print bran['Sales incl. tax ($)']
    saltax.append(bran['Sales incl. tax ($)'])
    salcoun.append(bran['Count'])


8.0
0.0
0.0
0.0
68.0
0.0
20.0
0.0
24.0
0.0
0.0
12.0
0.0
131.95
131.95

In [48]:
satxtot = sum(saltax)

In [49]:
satxtot


Out[49]:
395.9

In [50]:
for bran in tuejs:
    #print bran['Revenue ($)']
    print bran['Product']


Cappuccino
Cappuccino FREE
Chai Latte FREE
Espresso FREE
Flat White
Flat White FREE
Hot Chocolate
Hot Chocolate FREE
Long Black
Long Black FREE
Macchiato FREE
Mocha
Mocha FREE
Total
Grand Total

In [51]:
salcoun


Out[51]:
[2, 69, 15, 7, 17, 242, 5, 68, 6, 73, 4, 3, 61, 572.0, 572.0]

In [ ]:


In [ ]: