How to split all chars from string array

julia> (dane[1,5])

julia> split(dane[1,5],"")
4-element Array{SubString{String},1}:
is ok, 

julia> split.(string.(dane[:,5],""))
1074955-element Array{Array{SubString{String},1},1}:
 ["VENDI", "SERVIS", "Sp", "z", "oo"]

how to take all chars from this array not rows?

I am not exactly sure what you want to do or what type dane is, but here are a few examples that could help.

julia> a = ["asdxsad" "axsdaxds"; "fxssd" "dasd"]
2×2 Array{String,2}:
 "asdxsad"  "axsdaxds"
 "fxssd"    "dasd"

julia> split.(a,"x")
2×2 Array{Array{SubString{String},1},2}:
 ["asd", "sad"]  ["a", "sda", "ds"]
 ["f", "ssd"]    ["dasd"]

julia> split.(a[:,2],"x")
2-element Array{Array{SubString{String},1},1}:
 ["a", "sda", "ds"]

julia> split.(a[:],"x")
4-element Array{Array{SubString{String},1},1}:
 ["asd", "sad"]
 ["f", "ssd"]
 ["a", "sda", "ds"]

julia> join(a," ")
"asdxsad fxssd axsdaxds dasd"

julia> split(join(a," "),"x")
5-element Array{SubString{String},1}:
 "sad f"
 "ssd a"
 "ds dasd"

1 Like

With strings specifically, I’d go with split(join(array_of_strings), "") to get characters as strings or collect(join(array_of_strings)) to get them as Chars.

1 Like

Don’t use split(s, "") to get “characters” — that returns 1-character strings, but Julia (unlike Python) has an actual character type. Use collect to get an array of characters.

(That being said, it’s rare to actually need to explicitly collect an array of characters during string processing — you can just loop over the characters directly. Unlike other dynamic languages, you don’t have to cram everything into “vectorized” operations to get good performance; often non-vectorized code is clearer and faster.)


I think your parentheses is messed up.


Like other mentioned, you might want array of Char

1 Like