Skip to main content
Question

How to take only the latest data from an API that updates every week?


tm7
Contributor
Forum|alt.badge.img+1
  • Contributor

Hi 

Im reading an API with health data that updates every week. The goal is to aumomatize the process so FME reads this API every week to take out the new data. Now this API has an attribute called “temporal” which has values like this: “2024-W30” or “2020-W10” which is just the year and the calendar week. 

The data goes back several years and each week the last week gets added.

I only want to use the latest data each week so what I need is somekind of a filter that looks at the attribute “temporal” and only takes the data from the current year with the highest numbered week which corresponds to the data that got added last week.  

Any suggestions on how I could do this? Thanks in advance

3 replies

liamfez
Influencer
Forum|alt.badge.img+34
  • Influencer
  • August 15, 2024

One idea would be to create an attribute “CurrentWeek” and then you can run the data through a Tester, Passing only the data which has a “temporal” value that equals the “CurrentWeek”. You could create this “CurrentWeek” attribute a couple of ways.

You could use a DateTimeStamper and DateTimeConverter, with the output format %Y-W%U.

Alternatively you could create that attribute in an AttributeCreator or AttributeManager by setting the value to

@DateTimeFormat(@DateTimeNow(),%Y-W%U)

.

If you are able to, you can create this attribute beforehand and use it to only read the data that matches that attribute.


tm7
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • August 16, 2024

Thanks Im new to FME so this is very helpful.

I understand correctly that this attirbute should change by itself every week?


liamfez
Influencer
Forum|alt.badge.img+34
  • Influencer
  • August 19, 2024
tm7 wrote:

Thanks Im new to FME so this is very helpful.

I understand correctly that this attirbute should change by itself every week?

Yes, the attribute created using the dedicated DateTimeStamper transformer or the “@DateTimeNow()” method will keep up to date with the current week. Both methods get the current date and time when they run, and then the formatting part changes it to only display the year and week.


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