diff --git a/scripts/io.jl b/scripts/io.jl new file mode 100644 index 0000000000000000000000000000000000000000..dc068021a2a15969caed75f6f0b89660f04fcfbc --- /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 + +