Hi, I am using JuliaDB.jl package to upload CSV files but having problems with filtering or extracting some data.
using JuliaDB
# t = loadtable("MTab.csv")
# Assume that the CSV contains the following data
t = table([1,1,1,1,1,2,2,2,2,2], [1,2,3,4,5,1,2,3,4,5], [10,20,22,45,50,60,44,32,83,92]; names = [:Scenario, :ID, :Adj_MV])
# Extract the values in column Adj_MV for scenario 1
RValues = filter(i -> (i.Scenario == 1), select(t, (:Adj_MV)))
This gives the following error message:
ERROR: type Int64 has no field Scenario
Stacktrace:
[1] getproperty(::Int64, ::Symbol) at .\Base.jl:20
[2] (::var"#74#75")(::Int64) at .\none:1
[3] filter(::var"#74#75", ::Array{Int64,1}) at .\array.jl:2346
[4] top-level scope at none:0
A workaround is is to create a temporary table t2 and then use the select function.
t2 = filter(i -> (i.Scenario == 1), t)
RValues = select(t2,(:Adj_MV))
However, this does not seems to be an efficient way of doing it. Can anyone please propose a correction to the following line of code?
RValues = filter(i -> (i.Scenario == 1), select(t, (:Adj_MV)))
Also, can this process i.e. extract these values be done using the CSV.jl package?