I have the following lisp file, which is from the UCI machine learning database. I would like to convert it into a flat text file using python. A typical line looks like th
If you know that the data is correct and the format uniform (seems so at a first sight), and if you need just this data and don't need to solve the general problem... then why not just replacing every non-numeric with a space and then going with split?
import re
data = open("chorales.lisp").read().split("\n")
data = [re.sub("[^-0-9]+", " ", x) for x in data]
for L in data:
L = map(int, L.split())
i = 1 # first element is chorale number
while i < len(L):
st, pitch, dur, keysig, timesig, fermata = L[i:i+6]
i += 6
... your processing goes here ...