Mercurial > hg > webaudioevaluationtool
diff scripts/comment_parser.py @ 928:ba58cf8d0dbc
Score parsing: make csv from all XML files (one file per page ID, one column per fragment ID, one row per subject). Supports varying selections of pages and fragments across subjects. Generalised to 'page' (instead of 'song') and 'fragment' (instead of 'mix').
author | Brecht De Man <BrechtDeMan@users.noreply.github.com> |
---|---|
date | Sun, 31 May 2015 14:45:30 +0100 |
parents | 5db0069046d5 |
children | 97ebdb6b266a |
line wrap: on
line diff
--- a/scripts/comment_parser.py Sat May 30 18:12:32 2015 +0100 +++ b/scripts/comment_parser.py Sun May 31 14:45:30 2015 +0100 @@ -8,21 +8,21 @@ tree = ET.parse(file) root = tree.getroot() - # get list of all songs - for audioholder in root.findall("./audioholder"): # iterate over songs - song_name = audioholder.get('id') # get song name + # get list of all page names + for audioholder in root.findall("./audioholder"): # iterate over pages + page_name = audioholder.get('id') # get page name - # create folder [song_name] if not yet created - if not os.path.exists(song_name): - os.makedirs(song_name) + # create folder [page_name] if not yet created + if not os.path.exists(page_name): + os.makedirs(page_name) - # for song [song_name], print comments related to mix [id] - for audioelement in root.findall("*/[@id='"+song_name+"']/audioelement"): + # for page [page_name], print comments related to fragment [id] + for audioelement in root.findall("*/[@id='"+page_name+"']/audioelement"): audio_id = str(audioelement.get('id')) - # append to file [song_name]/[song_name]-comments-[id].csv - with open(song_name+'/'+song_name+'-comments-'+audio_id+'.csv', 'a') as csvfile: + # append to file [page_name]/[page_name]-comments-[id].csv + with open(page_name+'/'+page_name+'-comments-'+audio_id+'.csv', 'a') as csvfile: commentstr = root.find("*/[@id='" - + song_name + + page_name + "']/audioelement/[@id='" + audio_id + "']/comment/response").text