Strategy for making a list of sessions, properly ordered and formatted. 1. Read entire dft.tsv file into a list, liDft. 2. Sort by Source, then Document, then Page, then Section titles, if any. 3. currSource. currDoc, currPage = values in 1st record 4. Make settings list, liSettings 5. numKey = 0 while source == currSource && document == currDoc && page == currPage: for dftrec in liDft: [title,subtitle,composer,orig_comp,source,document,volume,date,page,editor,encoder,arranger,intabulator,contributor,concordances,piece,section,type,key,difficulty,ensemble,part,remarks,recording,facsimile,fronimo,PDF,midi,created,modified] = dftRec Collect values Add values that apply to the entire Setting Walk through Section Titles. If no Section Titles, then you have an list consisting of just one section. Insert values that apply to the entire section. Walk through Parts of the Section and make a list of Parts. If no parts designation, then there is an list of just one part. Use "ensemble" for the Part designation. Insert parts values for each Part in the list. Add new record to liSettings Increment numKey and add to beginning of this record currSource. currDoc, currPage = values in next arDft record 5. Write out arSettings as json file, using json.dumps() or by some other method.