"""
maze1.txt
4 4
o . o . o . o
-   -   .   -
o . o . o | o
.   -   .   .
o | o . o . o
.   -   .   -
o . o . o . o
"""
readfile = open('maze1.txt', 'r')
line = readfile.readline()
rowcount, colcount = [int(elem) for elem in line.strip().split(' ')]
rights = []
downs = []
chars = 'o', '   ', '.', '-', '|', ''
translated = 'o', '   ', '.', '-', '|', ''
while line:
    line = readfile.readline()
if chars[0] in line:
    for elem in line.strip().split(chars[0])[1:]:
        rights.append(translated[chars.index(elem.strip())])
else:
    for elem in line.strip().split(chars[1])[:colcount]:
        downs.append(translated[chars.index(elem.strip())])
readfile.close()
for i, elem in enumerate(rights):
    print(elem, divmod(i, colcount))
print('##')
for i, elem in enumerate(downs):
    pass
parsing from text file to graph (python)