Transform date range into series of dates

Hi Everyone,

I am working with some museum metadata that we are integrating into a library catalog. The date format for museum objects is often formatted as a range of years (eg. 1901-1924). However, for our discovery system to be able to read a range of years correctly it has to be formatted as a series like so: 1901;1902;1903;1904;ā€¦1924).

Iā€™m not sure how to approach this type of transformation without integrating a lot of individual record work on top of some GRELs. Anyone have a suggestion as to how I could accomplish this?

Many thanks!

Jessica

So this is a naive algorithm in GREL:

  1. We split the range ā€œ1901-1924ā€ on the dash.
  2. We use a variable called years to save the splitted range.
  3. We use forRange to enumerate all the years in the splitted range.
  4. We join the resulting array into a string using "; " as separator.
with(
  value.split("-"),
  years,
  forRange(
    years[0].toNumber(),
    years[1].toNumber()+1,
    1,
    year,
    year))
.join("; ")
1 Like