From 7ecc5e3f893d0387bbabead8516cc4b8382fc0f6 Mon Sep 17 00:00:00 2001 From: Johannes Schumann <johannes.schumann@fau.de> Date: Sun, 3 Nov 2019 01:30:47 +0100 Subject: [PATCH] Julia IO for GiBUU std event output file --- scripts/io.jl | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 scripts/io.jl diff --git a/scripts/io.jl b/scripts/io.jl new file mode 100644 index 0000000..dc06802 --- /dev/null +++ b/scripts/io.jl @@ -0,0 +1,40 @@ +using CSV + +""" + read_final_events(filepath::AbstractString) + +Function for reading the final events from the GiBUU output + +# Arguments +- `filepath::AbstractString`: filepath to the FinalEvents.dat +""" +function read_final_events(filepath::AbstractString) + file = open(filepath) + header = readline(file) + close(file) + raw_col_names = split(header)[2:end] + col_names = [String.(split(col,":"))[end] for col in raw_col_names] + CSV.read(filepath, + header=col_names, + delim=' ', + comment="#", + ignorerepeated=true, + types=[Int32, + Int32, + Int32, + Int32, + Float64, + Float64, + Float64, + Float64, + Float64, + Float64, + Float64, + Float64, + Int32, + Int32, + Float64 + ]) +end + + -- GitLab