R.Muralikrishnan, MPI for Empirical Aesthetics. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Licence. ############################## # Awk script to extract Know data: Music-Ratings and questionnaire data from Presentation Logfile # # Execute as: awk -f Extract-Know-Rating-Data.awk Logfiles/KN*-*.log >> Know-Rating-Data.txt # Same script works for both Know-1 and Know-2. # # IMPORTANT: The lines printed as ---Stim-Questions--- should be ignored...for they need to be put into # context as to which questions those answers pertain to. Since we missed logging the menu box (yes/no) # responses, we need to reconstruct these from the radio button responses. # See Know1-Filter-Questionnaire-Log.awk and Know1-Reconstruct-Questionnaire-Responses.awk for this purpose. # # # Author: R. Muralikrishnan ############################## BEGIN{FS = "\t";} # Sample Row from a Know1 logfile # KN001 7917 Nothing |Radio Button| 1 selected for angenehm...unangenehm. | ... # ... # ... # KN001 42702 Text Input Überraschend abwechslungsreich ... BEGINFILE{ TextInput = 0; MusicalPiece = 0; } { if ($3 == "Sound") {MusicalPiece = $4;} if ($3 != "Text Input") { gsub("selected for ","\"",$4); # Replace 'selected for ' with " gsub(/\. /,"\"",$4); # Replace a .[space] combination with " gsub("<b>","",$4); gsub("</b>","",$4); } if ($0 ~ /sehr/ && $0 ~ /Radio/) {QuestionType = "---Stim-Question---";} else {QuestionType = "Rating";} split($4,A1,"|"); if (A1[2] == "Radio Button") { if (A1[3] ~ /gar nicht...sehr gut/) { QuestionType = "---Composer-Question---";} if (TextInput == 0 && QuestionType == "Rating") { print $1, MusicalPiece, A1[3]; } else if (TextInput == 0 && QuestionType == "---Composer-Question---") { print $1, QuestionType, A1[3]; } # Stim-Question and K1-Questionnaire are extracted separately. } if ($3 == "Text Input") { gsub("\"","'",$4); # When there's a double-quote in the input text, we replace it with a single-quote gsub(/\r/,"",$4); # Some participants have pressed Enter (Windows \r) at the end of their text input...we just remove them. print $1, "---K1-TextInput--- ", "\""$4"\""; TextInput = TextInput + 1; } # This is only there for K1, for there's no Text Input in K2. }