#!/usr/bin/python3
import re

## ============================ One time initializations ========================
fileName = "female-first.txt"
outFileName = "female-first.csv"


## ============================ Open and process file(s) ========================

try:
    inFile = open(fileName,'r')
    outFile = open(outFileName,'w')

    count = 1
    runFlag = True
    while(1):            # Process while true

        line = inFile.readline()
        if line == "":              # Exit on empty line == end of file
            break

        line = line.rstrip("\n")
        line = line.lstrip().rstrip()
        print(count,line)
        csvLine = re.sub(' +',',',line)
        print("\t",csvLine)
        outFile.write(csvLine + "\n")
        count = count + 1

except:
    print("Some error occurred. Ending here")
    exit(-1)

inFile.close()
