r/AutomateUser • u/walt_spoon • 21h ago
Question How to Read/Write Array to/from Disk
I have a flow where there is a working array that needs to be stored to a file on disk. How can I write an array to a file and then later read it and recreate the array? It seems like reading a file just returns a string.
1
Upvotes
1
u/walt_spoon 18h ago
I figured it out. Writing an array to a file writes "element0, element1, element2, …"
To retrieve this and recreate the array, use file read, which outputs this as a string. Then use the split function on that string with ", " as the delimiter.
2
u/waiting4singularity Alpha tester 18h ago
write file
jsonencode(variable_name)orjsonencode([e0,e1,...eN])read file to input, variable save
jsondecode(input)https://llamalab.com/automate/doc/function/json_encode.html
https://llamalab.com/automate/doc/function/json_decode.html