Column read from dataframe is not equal to my string

I read a MySQL table whose values change frequently and put them in a dataframe (df). In my example, the content of the “d8” column is definitely equal to “GM.”
As mentioned above, the value of “d8” can vary, so I need to check its content and then act accordingly.
The piece of code says that val1 is not equal to “GM.”
Where am I going wrong?

val = df[!,“d8”]
val1 = string.(val)
println(val1)
println(typeof(val1))
    s = 0
    val1 != “GM” ? println(“NOK”) : s += 1

Below are the 3 values of println

> [“GM”]
> Vector{String}
> NOK

Did you try val1 != [“GM”] ?

Your first print statement shows val1 is a vector containing one string and not simply a string. So your test as written will fail.

You could alternatively use val1[1] to make the comparison with the first string in the vector.

1 Like

Both solution work as a charm