#!/usr/bin/env python
import sys
import csv

if len(sys.argv) == 1:
    print("Usage: moodle-destroyer moodle-file grading-file output-file")
    print("use in folder where your Zip is located")
    sys.exit(1)

MOODLE_EXPORT = sys.argv[1]
GRADING_FILE = sys.argv[2]
RESULT_FILE = sys.argv[3]

with open(GRADING_FILE, 'rU', newline='') as grading, \
    open(MOODLE_EXPORT, 'rU', newline='') as moodle, \
    open(RESULT_FILE, 'w', newline='') as result:
    reader_grading = csv.DictReader(grading)
    reader_moodle = csv.DictReader(moodle)

    header = reader_moodle.fieldnames 
    writer = csv.DictWriter(result, \
                            header, \
                            quotechar='"', \
                            quoting=csv.QUOTE_NONNUMERIC)
    writer.writeheader()   
    moodlelist = []
    gradinglist = []

    for line in reader_moodle:
        moodlelist.append(line)
    for line in reader_grading:
        gradinglist.append(line)

    for line in gradinglist:
        for row in moodlelist:
            #print(line['Gruppe'],"\nrow:",row['Gruppe'])
            if line['Gruppe'] == row['Gruppe']:
                    row['Bewertung'] = line['Bewertung']
                    row['Feedback als Kommentar'] = line['Feedback als Kommentar']
                    writer.writerow(row)

@@ -41,256 +41,880 @@
 csv%0A
-%0Aif len(sys.argv) == 1:%0A    print(%22Usage: moodle-destroyer moodle-file grading-file output-file%22)%0A    print(%22use in folder where your Zip is located%22)%0A    sys.exit(1)%0A%0AMOODLE_EXPORT = sys.argv%5B1%5D%0AGRADING_FILE = sys.argv%5B2%5D%0ARESULT_FILE = sys.argv%5B3%5D
+import argparse%0A%0Aparser = argparse.ArgumentParser(prog=%22Moodle Destroyer%22, prefix_chars=%22-%22)%0A%0Aparser.add_argument(%22-v%22, %22--version%22, help=%22WE ARE TALKING ABOUT THE VERSION%22)%0Aparser.add_argument(%22-g%22, %22--grading%22, help=%22ALL YOUR GRADINGS BELONG TO US%22)%0Aparser.add_argument(%22-m%22, %22--moodle%22, help=%22gimme the moodle stuff%22)%0Aparser.add_argument(%22-r%22, %22--result%22, help=%22name your result%22)%0A%0Aargs=parser.parse_args()%0A%0Aif len(sys.argv) == 1:%0A    print(%22Usage: moodle-destroyer moodle-file grading-file output-file%22)%0A    print(%22use in folder where your Zip is located%22)%0A    sys.exit(1)%0A%0A    if args.grading != None:%0A        GRADING_FILE = args.grading%0A    else:%0A        raise Exception%0A%0A    if args.moodle != None:%0A        MOODLE_EXPORT = args.moodle%0A    else:%0A        raise Exception%0A%0A    if args.result != None:%0A        RESULT_FILE = args.result%0A    else:%0A        raise Exception
 %0A%0Awi

add argumentparser