Forum Discussion
Another approach would be to use a Mapper Snap with the “Pass through” option set. The first transformation would copy $Field1
to $NEWNAME
and then the second would delete $Field1
(put $Field1
in the left side of the table and leave the right blank). I’m attaching a pipeline to demonstrate that:
RenameKey_2018_05_10.slp (4.4 KB)
Using mapKeys()
might be more involved than necessary for a single key. In your example, you would need to use a conditional to change the result for the key you are interested in:
$.mapKeys((value, key) => key == "Field1" ? “NEWNAME” : key)
$.mapKeys((value, key) => key == ‘Field1’ ? ‘NEWNAME’ : key) has worked fine for me.
Also the approach I was using already is the 2 mapper approach you have suggested. One mapper for copying and second to delete. But I thought if we use this $.mapKeys approach, we can do this with one mapper right. Thats why was thinking of the $.mapKeys approach.
Anyway Thanks a lot for that!! 🙂 🙂
- RogerSramkoski2 years agoEmployee
Hello nihit_g, welcome to the Community! 👋
At this point in time, SnapGPT does not have much if any access to assets like files, accounts, or pipelines within an organization. That's an area we're moving forward on cautiously as we and many of our customers want us to be careful not to expose sensitive data or metadata.
That said, I am curious if you could you share more about the error you see when trying to read the file? Is it a file not found error, or a insufficient permissions? What's the actual path that shows up in the File Reader? If we know more specifics about what you're seeing I can share that with the Product Management team.
Hi rsramkoski,
Thanks for the reply, I would like to elaborate the query regarding SnapGPT.
"Generate a pipeline to fetch "Global-Superstore.csv" file from path" Project /snaplogictrial/projects/My Folder", then filter it by removing all records except "India" as Country column, then load in the file writer."
I had used above prompt in SnapGPT and got pipeline generated and below are the things that came into picture.
- However, there is no error in the pipeline generation, Pipeline is somewhat correct as per my prompt used.
- Since CSV file is mentioned in the prompt, it is taking json parser and formatter as snap.
- In the pipeline, file reader snap should fetch the file which has been already uploaded to SLDB and its path and file name are also mentioned in the prompt.
But instead of fetching the file, it is simply taking that URL in the file reader snap which is mentioned in the prompt but not fetching the file like shown in the picture.
- SnapGPT doesn't validate itself once the pipeline it generates.
Thanks.
Nihit
- RogerSramkoski2 years agoEmployee
Thank you nihit_g! I will share this post with the SnapGPT Dev team as feedback.
Related Content
- 10 months ago