import sys, io

def main():
    if len(sys.argv) < 2:
        print('Please give the file name as argument');
        sys.exit(100);

    out_name = sys.argv[1].split('.')[-2] + '-processed.csv';
    
    with open(sys.argv[1], 'r', encoding='latin1') as original:
        with open(out_name, 'w') as out_file:
            original = original.read();
            lines = original.splitlines(False)[1:];
            for line in lines:
                line = line.replace('Auslagerung', 'out');
                line = line.replace('Einlagerung', 'in');
                line = line.replace('Papier', 'paper');
                line = line.replace('Holz', 'wood');
                line = line.replace('Stein', 'stone');
                line = line.replace('Weiß', 'white');
                line = line.replace('Blau', 'blue');
                line = line.replace('Grün', 'green');
                line = line.replace('A3', 'a3');
                line = line.replace('A4', 'a4');
                line = line.replace('A5', 'a5');
                line = line.replace('Buche', 'beech');
                line = line.replace('Kiefer', 'pine');
                line = line.replace('Eiche', 'oak');
                line = line.replace('Bretter', 'boards');
                line = line.replace('Balken', 'beams');
                line = line.replace('Scheit', 'pieces');
                line = line.replace('Marmor', 'marble');
                line = line.replace('Granit', 'granite');
                line = line.replace('Sandstein', 'sandstone');
                line = line.replace('Leicht', 'light');
                line = line.replace('Mittel', 'medium');
                line = line.replace('Schwer', 'heavy');
                parts = line.split(';');

                out_file.write(parts[1] + ',' + parts[2] + ',' + parts[5] + ',' + parts[3] + ',' + parts[4] + '\n');



if __name__ == '__main__': main();
