โ09-25-2018 07:12 AM
Iโm brand new to Snaplogic and this is probably really easy - sorry in advance! But Iโve been stuck on this since Thursday, and itโs now Tuesdayโฆ please help me.
As a whole, I have this:
In more detail:
I have a JSON splitter, which has an output of the JSON I want to write to a CSV. And, if I preview the output in table view, it looks exactly like the CSV I want (I had an image here, but new users can only put one - sorry!). Previewing in JSON shows that itโs, well, JSON.
After that, I have a CSV formatter, but I donโt have anything configured in it. Should I? The output view for this is more or less empty, so this clearly isnโt correct. Iโve tried JSON formatters and a million other things here. I just donโt know.
Then I have my file writer (and as a bonus, I want only some of the fields from the JSON to be written to the CSV file).
I can do it in Python:
# Call the API
r = requests.get(url_to_call, headers = headers)
json_to_write = r.json()
# Open a file for writing
outfile = open(file_name,'w')
writer=csv.writer(outfile)
# Write CSV Header Row
writer.writerow(["Id", "FirstName", "LastName"])
# Loop through each line of the JSON; print key values needed
for x in json_to_write:
writer.writerow([x["Id"],
x["FirstName"],
x["LastName"]])
I found this post on turning JSON to CSV by @dmiller and this post on writing a Twitter Query to a file, but as far as I can tell, those are just โuse these snapsโ without showing how the snaps are configured, and Iโve tried those configurations of snaps.
Iโm so lost. Any help appreciated.
โ09-25-2018 07:30 AM
Hmm, can you reply to your own message with the screenshot of the preview to workaround?
(We might want to look into removing this restriction)
Can you download the pipeline (see here) and attach it here so we can take a look at the configuration?
The default configuration of the CSV formatter should probably just work.
โ09-25-2018 07:55 AM
Thanks for your reply!
Thatโs a good idea. I hit the one image limit again, so I put it all together in one image.
(Note that Iโm only pulling Id, FirstName, LastName, and Username from the JSON - it has a lot in it).
Iโll look at that doc on downloading the pipeline and get back to you in another reply. I have to scrub it of all the private info first).
โ09-25-2018 08:24 AM
Looking into the image restriction now @tstack
Bumped it up to 5 for now.
โ09-25-2018 08:11 AM
Okay - theoretically itโs attached.ISS Example_2018_09_25(1).slp (6.5 KB)
(I changed the API to a test API, but it has the same structure as my data, so if we can get this working, my data should also work). Thank you!