def makeCsvList(prices, containers):
    # creates a list of lines to print to a csv file, looks like:
    # item name     buy price       sell price      item id
    csvList = []
    for x in prices:
        id = x['id']
        # get the item object from the containers list provided
        item = gw2lib.findByID(id, containers)
        # use formatCoins from gw2lib to get the buy and sell price in gold for each entry in prices
        buyCoins = gw2lib.formatCoins(x['buys']['unit_price'],'gold')[0]
        sellCoins = gw2lib.formatCoins(x['sells']['unit_price'],'gold')[0]
        # put it all in a list, and append that list to the csvList (of lists)
        csvLine = [ item['name'], buyCoins, sellCoins, id ]
        csvList.append(csvLine)
    return csvList
    print ''
'''
# trimmed recipes is used to get only recipes whose final item can be sold on trade, to look at profits that can be made
trimmedRecipes = []
# for each recipe:
for rec in recipeChecks:
    # if its source is the trading post
    if rec['costInfo']['source'] == 'trading post':
        # calculate the difference when using all the buy or sell prices of the ingredients and the trade price
        rec['buyDiff'] = rec['costInfo']['buyPrice']*0.85 - rec['costInfo']['craftBuyPrice']
        rec['sellDiff'] = rec['costInfo']['sellPrice']*0.85 - rec['costInfo']['craftSellPrice']
        # and append it to the trimmed list
        trimmedRecipes.append(rec)

# sort the list to show only the x best recipes
trimmedRecipes = sorted(trimmedRecipes, cmp=compByBuyDiff, reverse=True)

# and go through each recipe, recursively, and output its info
for rec in trimmedRecipes[:10]:
    print 'source id: ' + str(rec['sourceID']) + ', name: ' + rec['name'] + ', tp buy, sell: ' +\
          gw2lib.formatCoins(rec['costInfo']['buyPrice'])[2] + ', ' + gw2lib.formatCoins(rec['costInfo']['sellPrice'])[2] +\
          ', crafting buy, sell: ' + gw2lib.formatCoins(rec['costInfo']['craftBuyPrice'])[2] + ', ' +\
          gw2lib.formatCoins(rec['costInfo']['craftSellPrice'])[2] + ', diffs: ' + gw2lib.formatCoins(rec['buyDiff'])[2]\
          + ', ' + gw2lib.formatCoins(rec['sellDiff'])[2]
    printTrimRecTrail(rec['ingredients'])
    print ''

end = time.time()

print (end-start)/60, 'minutes'