Changeset 7518


Ignore:
Timestamp:
27 Jan 2012, 06:54:13 (13 years ago)
Author:
Henrik Bettermann
Message:

Filename is now an argument of the script.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/tools/fix_import_file.py

    • Property svn:keywords set to Id
    r7516 r7518  
    1 ##
    2 ## fix_import_file.py
    3 ## Login : <uli@pu.smp.net>
    4 ## Started on  Wed Jan 25 17:08:30 2012 Uli Fouquet
    51## $Id$
    62##
    7 ## Copyright (C) 2012 Uli Fouquet
     3## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann
    84## This program is free software; you can redistribute it and/or modify
    95## it under the terms of the GNU General Public License as published by
     
    2117##
    2218"""
    23 Fix exports from old SIRP portal to make them importable by current portal.
     19Fix exports from old SRP portal to make them importable by current portal.
    2420
    2521Usage:
     
    2824to be in the same directory) and then run
    2925
    30   python fix_import_file.py
     26  python fix_import_file.py <filename>
    3127
    3228Errors/warnings will be displayed on the shell, the output will be put
     
    3430"""
    3531
     32import sys
     33
     34
     35if len(sys.argv) != 2:
     36    print 'Usage: python fix_import_file.py <filename>'
     37    sys.exit(1)
     38
    3639##
    3740## CONFIGURATION SECTION
    3841##
    3942# file with input data
    40 INPUT_FILE = 'students_for_reimport.csv'
     43INPUT_FILE = '%s' % sys.argv[1]
    4144
    4245# file written with modified output
    43 OUTPUT_FILE = 'out.csv'
     46OUTPUT_FILE = '%s_edited.csv' % sys.argv[1].split('.')[0]
    4447
    4548# keys are fieldnames in input file, values are methods of class
     
    5659# Mapping input file colnames --> output file colnames
    5760COLNAME_MAPPING = {
    58     'jamb_reg_no': 'reg_no',
     61    'jamb_reg_no': 'reg_number',
    5962    'birthday': 'date_of_birth',
    6063    }
     
    172175    writer.writerow(row)
    173176
    174 print "Ouput written to %s" % OUTPUT_FILE
     177print "Output written to %s" % OUTPUT_FILE
Note: See TracChangeset for help on using the changeset viewer.