From f822d5efad930b26f8a4fe24bc802d44d1f22a15 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 30 Apr 2013 17:24:34 +0200 Subject: Many fix on CSV imports - allow to import only slice of rows --- .../management/commands/import_operations.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'archaeological_operations/management') diff --git a/archaeological_operations/management/commands/import_operations.py b/archaeological_operations/management/commands/import_operations.py index 3cf4a569d..acc43a591 100755 --- a/archaeological_operations/management/commands/import_operations.py +++ b/archaeological_operations/management/commands/import_operations.py @@ -28,7 +28,7 @@ IMPORTERS = {'csv':import_from_csv, 'vfp':import_from_dbf} class Command(BaseCommand): - args = ' [ ]' + args = ' [ ]' help = "Import archaelogical operations" def handle(self, *args, **options): @@ -36,7 +36,8 @@ class Command(BaseCommand): raise CommandError("No file provided.") filename = args[0] update = len(args) > 1 and args[1] - file_type = len(args) > 1 and args[2] + file_type = len(args) > 2 and args[2] + lines = len(args) > 3 and args[3] if not file_type: suffix = filename.split('.')[-1].lower() if suffix in IMPORTERS.keys(): @@ -48,7 +49,8 @@ class Command(BaseCommand): raise CommandError("This file type is not managed.") nb_ops, errors = IMPORTERS[file_type](filename, update=update, - stdout=self.stdout) + stdout=self.stdout, + lines=lines) self.stdout.write('\n* %d operation treated\n' % nb_ops) if errors: self.stderr.write('\n'.join(errors)) -- cgit v1.2.3