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
  • 55 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

ronnie.utter wrote:

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

View original
Did this help you find an answer to your question?

7 replies

nielsgerrits
VIP
Forum|alt.badge.img+54

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
  • February 15, 2021
nielsgerrits wrote:

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+32
  • Influencer
  • 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
  • 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
  • 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+32
  • Influencer
  • Best Answer
  • February 15, 2021
ronnie.utter wrote:

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
  • February 15, 2021
ebygomm wrote:

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings