aboutsummaryrefslogtreecommitdiffstats
path: root/servo/management/commands
diff options
context:
space:
mode:
Diffstat (limited to 'servo/management/commands')
-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