Esempio n. 1
0
    def handle(self, *args, **kwargs):

        with open(
                '/Users/alexanderwarnes/Documents/abw_codes/Git/5E Rules CSVs/5E Rules CSVs/Items-Table 1.csv'
        ) as f:
            items = pd.read_csv(f, delimiter=',')

        items = items.dropna()

        for item in items.iterrows():

            item_entry = Item(
                name=item[1][0],
                item_type=item[1][1],
                description=item[1][2],
                weight=item[1][3],
                material=item[1][4],
                cost_copper=item[1][5],
                cost_silver=item[1][6],
                cost_gold=item[1][7],
                cost_platinum=item[1][8],
                special=item[1][9],
                uses=item[1][10],
                space=item[1][11],
            )

            item_entry.save()
Esempio n. 2
0
def process_data(number_list, options):
    """
    Take a list of numbers and create a new equipment item for each. ItemType is specified in options.itemtype.
    """
    check_data(number_list, options)
    added_count = 0
    for number in number_list:
        number = number.upper()  # Normalize to upper case
        if options.hipnumber:
            new_item = Item(itemtype=options.itemtype, hip_number=number)
        else:
            new_item = Item(itemtype=options.itemtype, serialnumber=number)
        if options.add:
            new_item.log_this("Added from %s" % options.datafile)
            new_item.save()
            added_count += 1
    print "Added %s new items (%s)" % (added_count, options.itemtype)