# \author Kurak
# skrypt pobiera tekst z stdin az do napotkania pojedynczej linijki 'end',
# a nastepnie otwiera consts.csv w kazdym scenariuszu i dodaje linijki na koniec tych plikow
import sys
import glob

lines = []
while True:
    newline = sys.stdin.readline().strip()
    if newline == "end":
        break
    else:
        lines.append(newline)
    #if..else
#while

# Dopelnienie kazdej linijki srednikami coby zachowac format :)
def expandLineWithSemicolons(line):
    elems = line.split(";")
    return (line + ";" * (18 - len(elems)))
#expandLineWithSemicolons
lines = [expandLineWithSemicolons(line) for line in lines]

# Teraz wlasciwe doklejanie
def appendFileWithLines(file):
    print "Appending file \"" + file + "\" with " + str(len(lines)) + " new lines"
    f = open(file, "at")
    for newLine in lines:
        f.write("\n" + newLine)
    #for
    f.write("\n")
    f.close()
#appendFileWithLines

consts = glob.glob("./*/consts.csv")
for constsCsv in consts:
    appendFileWithLines(constsCsv)
#for

print "Done."
sys.stdin.read(1)