Below is a piece of code that I use to analyze values retrieved from MySQL and placed in a data frame.
The if… part is still in its infancy, so please don’t judge it too harshly.
val = df[!,"d8"]
println("val ", val)
val1 = string.(val)
println("val1 ", val1)
aa =length(val)
println(aa," ", val)
ab = length(val1)
println(ab," ", val1)
if length(val1) == 1
val1[1] in valid_values ? println("OK val1[1]") : println(val1[1], " THE VALUE IS NOT PRESENT IN 'valid_values' ARRAY ")
else val1 in valid_values ? println("OK val1") : println(val1, " THE VALUE IS NOT PRESENT IN 'valid_values' ARRAY ")
The values read from the database can be one or two characters long. Depending on this value and the value of the variable, the program evolves differently.
The problem arises when I try to determine the length of the variable. In both cases, the length is 1, which does not seem correct to me.
Below are some printouts with two- and single-character strings.
val Union{Missing, String}["S"]
val1 ["S"]
1 Union{Missing, String}["S"]
1 ["S"]
OK val1[1]
val Union{Missing, String}["GM"]
val1 ["GM"]
1 Union{Missing, String}["GM"]
1 ["GM"]
OK val1[1]