From cef2dc31b06c7070c5a4e7e3e608402230e1e4b2 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Fri, 16 Oct 2015 13:05:01 +0300 Subject: WIP add CSV price update command --- servo/management/commands/updateprices_csv.py | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 servo/management/commands/updateprices_csv.py (limited to 'servo') diff --git a/servo/management/commands/updateprices_csv.py b/servo/management/commands/updateprices_csv.py new file mode 100644 index 0000000..09f4147 --- /dev/null +++ b/servo/management/commands/updateprices_csv.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +from django.core.management.base import BaseCommand + +from servo.lib import ucsv +from servo.models import Product + + +class Command(BaseCommand): + + help = "Update product prices from CSV file" + + def add_arguments(self, parser): + parser.add_argument('path', nargs='+', type=str) + + def handle(self, *args, **options): + """ + CODE + NAME + DESCRIPTION + PRICE_EXCHANGE + """ + f = open(options['path'][0], 'rUb') + raw = ucsv.read_excel_file(f) + clean = [r for r in raw if r[0] != ''] + + for i in clean: + print i -- cgit v1.2.3