
# https://www.globalsino.com/ICs/
# Text file for the bank of all words, characters and strings


theBank = r"C:\0Python\theWordCharacterStringSymbolBank.txt"
theBankB = r"C:\0Python\theWordCharacterStringSymbolBankB.txt"
theBankC = r"C:\0Python\theWordCharacterStringSymbolBankC.txt"

# Replace space by changing a line
MyList = []
with open (theBank, 'r', encoding = 'utf-8') as f:
    for line in f.readlines():
        MyList.append(line)
Remove_colon = []
for i in MyList:
    Go_For_It = i.replace(' ', '\n')
    Remove_colon.append(Go_For_It)
with open (theBankB, 'w', encoding = 'utf-8') as MyNewFILEi:
    for ii in Remove_colon:
        MyNewFILEi.write(ii + '\n')

# Remove empty lines and duplicate lines (but keep the first line) in a text file
#import sys
with open(theBankB, encoding = 'utf-8') as f:
    for line in f:
        if not line.isspace():
            # sys.stdout.write(line)
            with open (theBankC, 'a', encoding = 'utf-8') as FileWithoutEmptyLines:
                FileWithoutEmptyLines.write(line)

# Form a string with all the items in the text file.
theFinalList = []
with open (theBankC, 'r', encoding = 'utf-8') as FinalTXTfile:
    for theLine in FinalTXTfile.readlines():
        jj = theLine.replace("\n", "")
        theFinalList.append(jj)
print(theFinalList)



