Skip to main content
Solved

[Solved] Export attributes and value from JSON that are not in the documentation for the output but exists in the query

  • February 15, 2021
  • 7 replies
  • 79 views

ronnie.utter
Contributor
Forum|alt.badge.img+11

Edit: The DateTime did exist in the output in the "Time" attribute as a ISO8601 format.

 

Problem.

I want to add starttime and endtime as attributes to the export.

 

I have a working simple workspace that reads a JSON from:

 

https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&starttime=@Value(date_sub)&endtime=@Value(date)

 

where starttime (value) and endtime(value) are in the format "yyyy-mm-dd" and is created as FME parameters.

 

The string original looks like this

https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&starttime=yyyy-mm-dd&endtime=yyyy-mm-dd

 

I am exposing the attributes I want with attribute exposer and it works at it should according to the documentation "GeoJSON Summary Format (usgs.gov)"

 

The starttime and endtime attributes is the date window where I want to read the event data from USGS.

 

So I guess there is timedata from the earthquake event that stores the date when its monitored. That is the data and time I want to get.

 

 

Best answer by ebygomm

I was not able to convert the time with the default DateTimeConverter transformer but I found a custom transformer that worked fine and then i added DateTimeConverter to get %y%m%d format.

I could probably tweak the python code to fix the date it without the DateTimeConverter. But this solution works fine and I am happy for now.

 

Thank you all. !!!

The DateTimeFormatter should work as long as you divide by 1000 first, and the s in %s must be lowercase

Capture

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

7 replies

nielsgerrits
VIP
Forum|alt.badge.img+60
  • 2938 replies
  • February 15, 2021

In the FeatureReader, set Attribute Accumulation Mode from "Only Use Result" to "Merge Initiator and Result".

2021-02-15_16h49_41


ronnie.utter
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • 37 replies
  • February 15, 2021

In the FeatureReader, set Attribute Accumulation Mode from "Only Use Result" to "Merge Initiator and Result".

2021-02-15_16h49_41

Hello,

Thank you for your answer. I edit my question since I understand I put it wrong.

Your answer is correct due to my question.

 

But now i have adjust my question with this lines.

 

The starttime and endtime attributes is the date window where I want to read the event data from USGS.

 

So I guess there is time data from the earthquake event that stores the date when its monitored. That is the data and time I want to get.


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • February 15, 2021

There is a time returned in the data which looks like a UNIX timestamp, you should be able to convert this to a datetime by dividing by 1000 and then using a DateTimeConverter with input %s


ronnie.utter
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • 37 replies
  • February 15, 2021

aa,, ok. I was wondering what kind of timeformat that was. Thanks. I will try that.


ronnie.utter
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • 37 replies
  • February 15, 2021

I was not able to convert the time with the default DateTimeConverter transformer but I found a custom transformer that worked fine and then i added DateTimeConverter to get %y%m%d format.

I could probably tweak the python code to fix the date it without the DateTimeConverter. But this solution works fine and I am happy for now.

 

Thank you all. !!!


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • Best Answer
  • February 15, 2021

I was not able to convert the time with the default DateTimeConverter transformer but I found a custom transformer that worked fine and then i added DateTimeConverter to get %y%m%d format.

I could probably tweak the python code to fix the date it without the DateTimeConverter. But this solution works fine and I am happy for now.

 

Thank you all. !!!

The DateTimeFormatter should work as long as you divide by 1000 first, and the s in %s must be lowercase

Capture


ronnie.utter
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • 37 replies
  • February 15, 2021

The DateTimeFormatter should work as long as you divide by 1000 first, and the s in %s must be lowercase

Capture

Thanks,

Ive learned something new today.

It works.