Changeset 9170 for src/django_gheat/gheat/management/commands
- Timestamp:
- May 9, 2011, 5:35:32 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/gheat/management/commands/import_droidstumbler.py
r9165 r9170 2 2 # -*- coding: utf-8 -*- 3 3 # 4 ###########################################5 #6 4 # Script for importing DroidStumbler .csv files 7 5 # 8 # In theory, only the -f option is needed, but for overview's sake, please use the others aswell. 9 # -f = location of the .netxml, e.g. '/home/test.csv' 10 # -m = name of the dataset, e.g. 'Walk in park' or 'Trip with boat' 11 # -g = your name 12 # -e = your email address 6 # Original by Dennis Wagenaar <d.wagenaar@gmail.com> 13 7 # 14 # (Run from project root) 15 # ./manage.py import_droidstumbler -f <file location> -m <dataset name> -g <username> -e <email> 8 # Rick van der Zwet <info@rickvanderzwet.nl> 16 9 # 17 # Make sure the variables in this script match the column numbers in your file e.g.;18 # Lat is read from the first column [0], if the lat in your file is in the 4th column, change19 # 'lat = row[0]' to 'lat = row[3]'.20 # Also, take note of the 'replace()' and 'strip()' functions. These should probably be edited aswell.21 #22 # Dennis Wagenaar23 # d.wagenaar@gmail.com24 #25 ###########################################26 27 10 from django.core.management import setup_environ 28 11 from django.core.management.base import BaseCommand, CommandError … … 31 14 import csv 32 15 import datetime 16 import gzip 33 17 import os 34 18 import sys … … 40 24 mr = MeetRondje.objects.create(datum=datetime.datetime.now() , naam=meetrondje , gebruiker=g , apparatuur=a) 41 25 42 csvfile = csv.reader(open(location, 'rb'), delimiter=',') 26 if location.endswith('.gz'): 27 fh = gzip.open(location,'rb') 28 else: 29 fh = open(location,'rb') 30 csvfile = csv.reader(fh, delimiter=',') 43 31 count = 0 44 32 ap_cache = {} … … 68 56 69 57 class Command(BaseCommand): 70 args = '<csvfile> '58 args = '<csvfile>[.gz]' 71 59 option_list = BaseCommand.option_list + ( 72 60 make_option('-m', '--meetrondje', dest='meetrondje', default='rondje'),
Note:
See TracChangeset
for help on using the changeset viewer.