From 10357d86ca17efd1a9e32950884fc27264a688d0 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 3 Sep 2024 17:50:16 -0500 Subject: [PATCH] feat: Add response sorting script --- main.jl | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 main.jl diff --git a/main.jl b/main.jl new file mode 100755 index 0000000..334dc37 --- /dev/null +++ b/main.jl @@ -0,0 +1,36 @@ +#!/usr/bin/env julia +using CSV +using DataFrames +using Mustache + +# Import data +survey_data = DataFrame(CSV.File("data.tsv"; delim='\t', normalizenames=true)) +deleteat!(survey_data, 2) + +# Set descriptions of each column based on the actual question asked +for (i, col) in enumerate(eachcol(survey_data)) + colmetadata!(survey_data, i, "description", first(col)) +end #for + +# Remove the messy JSON encoding +# TODO: For later graphs, move this step _before_ the import so that DataFrames can properly +# infer types +# deleteat!(survey_data, [1,2]) + +# Compile comments from all requested questions +questions = [:Q8, :Q16, :Q29, :Q30] +for q in questions + open("$q.md", "w") do f + write(f, "# Antimicrobial usage survey open-ended question: $q\n\n") + for (i, a) in enumerate(skipmissing(survey_data[!, q])) + if i == 1 + write(f, "**$a**\n\n") + else + write(f, "$a\n\n") + end #if + end #for + end #do + + run(`pandoc $q.md -o $q.docx`) + +end #for