aboutsummaryrefslogtreecommitdiffstats
path: root/servo/management
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2015-10-16 13:05:01 +0300
committerFilipp Lepalaan <filipp@mac.com>2015-10-16 13:05:01 +0300
commitcef2dc31b06c7070c5a4e7e3e608402230e1e4b2 (patch)
treee085c0aa8bde1726affbadc6a7d7feda950a353c /servo/management
parenta7bed71c6431342ceb0503171eaab26c119f2223 (diff)
downloadServo-cef2dc31b06c7070c5a4e7e3e608402230e1e4b2.tar.gz
Servo-cef2dc31b06c7070c5a4e7e3e608402230e1e4b2.tar.bz2
Servo-cef2dc31b06c7070c5a4e7e3e608402230e1e4b2.zip
WIP add CSV price update command
Diffstat (limited to 'servo/management')
-rw-r--r--servo/management/commands/updateprices_csv.py28
1 files changed, 28 insertions, 0 deletions
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