Add a row to dataframe, fill it with integers and sum the values

I’m writing a script where a user can add a row to a dataframe (df2) and fill in some integer values (1 through 9). What I have is this:

n_rows = nrow(df2)
println("Give sores for", n_rows, " rows: ")
scores_temp = readline()
scores = split(scores_temp, " ")
parse.(Int64, scores)
for i in 1:length(scores)
      scores[i] = scores[i]
end
df2[:, "Score"].= scores
println(df2)
tot_score = sum(df2[!, :Score]) # this doesn't work!
println(tot_score)

All goes wel, but when summing the added column (:Score) I get an error:

ERROR: MethodError: no method matching +(::SubString{String}, ::SubString{String})

I tried different summing methods. But I can’t find the mistake I make.

None of this really does anything. You just want

df2[:, "Score"] = parse.(Int64, scores)

except maybe you want more logic there like tryparse + something in case the input is not integer.

Thnx tbeason, that works very well! Less is better and still learning :smile