I noticed some of the code ITT leaves a trailing empty element:
, ""] because the last | in the data has nothing after it
HiSoKa wrote: ↑04 Dec 2022, 14:40
I agree, but how i can create table
How I might parse it into a table:
Code: Select all
A := new biga() ; requires https://github.com/biga-ahk/biga.ahk
myDataStruct := []
Data =
(
Name1|Lname1|123456789|Name2|Lname2|123456789|Name3|Lname3|123456789|Name4|Lname4|123456789|
)
chunks := A.chunk(strSplit(Data, "|"), 3)
for key, value in chunks {
if (value.1 != "") {
myDataStruct.push({"firstName":value.1, "lastName":value.2, "phone":value.3})
}
}
; => [{"firstName":"Name1", "lastName":"Lname1", "phone":"123456789"}
; , {"firstName":"Name2", "lastName":"Lname2", "phone":"123456789"}
; , {"firstName":"Name3", "lastName":"Lname3", "phone":"123456789"}
; , {"firstName":"Name4", "lastName":"Lname4", "phone":"123456789"}]
You can also call a table an "Array of Objects"
That's how I like to think of it.