Harini
Harini2y ago

string to array derivative

Hi @Rambo we currently do not support import of complex fields like array with csv. We will be improving this in the future releases. In the meantime you can import them as a text field and have another derivate column to parses them into to stored into a Firestore array field.
8 Replies
SeanS
SeanS2y ago
Hi @harini I found the docs for creating a derivative field and understand how this works, but I'm not a dev and wondering if you have a example of what's needed to parse a text field and then store it as an array in another column?
Harini
Harini2y ago
Hi @SeanS you can use the following code to convert a string to an array using derivative.
return JSON.parse(row.arrayString);
return JSON.parse(row.arrayString);
Derivative field listens to the string and converts to array and stores it in that field.
No description
SeanS
SeanS2y ago
Awesome. Thank you! This seems pretty straightforward, but I wasn't able to get it to run. Feel like I'm missing something simple and obvious, but don't know what it is. It simply doesn't seem to run, regardless of the trigger I use. I created a derivative column (activityStepsArray) with a trigger from both source column (activitySteps). I added the following code to the derivative with the source field: return JSON.parse(row.activitySteps); But, no luck. Maybe the format of the content is wrong? I was just using simple line breaks, but have also tried this format: `[ "Whenever you hear your child babbling or chatting, imitate their sounds", "They say ""bababababa"" while looking out the window of the car, you repeat it", "Some kids may require a gentle entrance into this activity, even repeating them in a whisper may be best", "Some kids will need a higher energy response, maybe singing their babbled sounds is best to get their attention", "We are trying to establish the game of vocal imitation by imitating them", "Use fun facial expressions and movements if your child enjoys them", "Be silly, have fun!", ]' Any suggestions? I'll post a screenshot below.
SeanS
SeanS2y ago
No description
Harini
Harini2y ago
Is the field type of activitySteps a text field?
SeanS
SeanS2y ago
Yes. Should it be something else? JSON? Code? I tried JSON without luck. If so, what would be the proper format?
Shams
Shams2y ago
text field is fine, the problem here looks like is the double qoutes on the second line "They say ""bababababa"" while looking out the window of the car, you repeat it", and the last comma before the closing bracket
SeanS
SeanS2y ago
SOLVED: met with Shams (thank you!) solved my formatting issues, and gained clarity on using derivative columns.