# L-17 MCS 260 : bkfrom2list
"""
Converts existing formats of books on file as

  1:1:Computer Science.  An Overview:
  0:2:Python Programming in Context:

into

  [True, 1, 'Computer Science.  An Overview']
  [False, 2, 'Python Programming in Context']
"""
with open('books.txt', 'r', encoding='utf-8') as INFILE:
    with open('bookslist.txt', 'w', encoding='utf-8') as OUTFILE:
        while True:
            LINE = INFILE.readline()
            if LINE == '':
                break
            DATA = LINE.split(':')
            NEWD = [DATA[0] == '1', int(DATA[1]), DATA[2]]
            OUTFILE.write(str(NEWD) + '\n')
        OUTFILE.close()
    INFILE.close()
