def main(): #program options usage = "usage: %prog [options] -i inputfile -o outputfile" parser = OptionParser(usage=usage) parser.add_option( "-i", "--input", action="store", type="string", dest="input", help="Stammdaten-CSV von 50Hertz. Muss angegeben werden!", metavar="FILE") parser.add_option( "-o", "--output", action="store", type="string", dest="output", help="Uniforme Ausgabe-Datei(csv). Muss angegeben werden!", metavar="FILE") parser.add_option("-f", "--filter", action="store", type="string", dest="filter", help="Filterdatei", metavar="FILE") (options, args) = parser.parse_args() if not options.input: parser.error("Error: no input file. Use options -h for usage details.") if not options.output: parser.error( "Error: no output file. Use options -h for usage details.") filterSet = [] if options.filter: filterSet = parseFilterSet(options.filter) writeUniCsv(options.output, parseNetzLeipzigPdfFile(options.input), filterSet)
def main(): #program options usage = "usage: %prog [options] -o outputfile UNICSV_INPUT1 UNICSV_INPUT2 ... UNICSV_INPUTN" parser = OptionParser(usage=usage) parser.add_option( "-i", "--inconsistency", action="store", type="string", dest="incons", help="CSV-Datei in der Inkonsistenzen gespeichert werden", metavar="FILE") parser.add_option( "-o", "--output", action="store", type="string", dest="output", help="Uniforme Ausgabe-Datei(csv). Muss angegeben werden!", metavar="FILE") parser.add_option("-f", "--filter", action="store", type="string", dest="filter", help="Filterdatei, Output-Filter", metavar="FILE") parser.add_option( "-b", "--behavior", action="store", type="string", dest="behavior", help= "Verhalten bei Inkonsistentz: TAKE_FIRST,TAKE_SECOND, TAKE_NONE(default)", metavar="MODE", default="TAKE_NONE") (options, args) = parser.parse_args() if len(args) < 2: parser.error( "Error: too few input files. Use options -h for usage details.") if not options.output: parser.error( "Error: no output file. Use options -h for usage details.") filterSet = [] if options.filter: filterSet = parseFilterSet(options.filter) entrySets = [] for arg in args: entrySets.append(readUniFile(arg)) incons_statistics = [0 for i in range(len(entrySets[0][0]) - 1)] (mergedEntries, inconsEntries) = mergeUniEntries(entrySets, options.behavior, incons_statistics) writeUniCsv(options.output, mergedEntries, filterSet) if options.incons: writeUniCsv(options.incons, inconsEntries, filterSet) print "Inkonsistenzverteilung:" for i in range(len(incons_statistics)): print attributeMap[i], " : ", incons_statistics[i]
def main(): #program options usage = "usage: %prog [options] -o outputfile UNICSV_INPUT1 UNICSV_INPUT2" parser = OptionParser(usage=usage) parser.add_option( "-i", "--inconsistency", action="store", type="string", dest="incons", help="CSV-Datei in der Inkonsistenzen gespeichert werden", metavar="FILE") parser.add_option( "-o", "--output", action="store", type="string", dest="output", help="Uniforme Ausgabe-Datei(csv). Muss angegeben werden!", metavar="FILE") parser.add_option("-f", "--filter", action="store", type="string", dest="filter", help="Filterdatei, Output-Filter", metavar="FILE") parser.add_option( "-b", "--behavior", action="store", type="string", dest="behavior", help= "Verhalten bei Inkonsistentz: TAKE_FIRST,TAKE_SECOND, TAKE_NONE(default)", metavar="MODE", default="TAKE_NONE") (options, args) = parser.parse_args() if len(args) < 2: parser.error( "Error: too few input files. Use options -h for usage details.") if not options.output: parser.error( "Error: no output file. Use options -h for usage details.") filterSet = [] if options.filter: filterSet = parseFilterSet(options.filter) entries1 = readUniFile(args[0]) entries2 = readUniFile(args[1]) (mergedEntries, inconsEntries) = mergeUniEntries(entries1, entries2, options.behavior) writeUniCsv(options.output, mergedEntries, filterSet) if options.incons: writeUniCsv(options.incons, inconsEntries, filterSet)