0

I want to transform following Column:

Col_openingHours: 1: Mo-Sa: 03:00 - 11:00 | 2: Mo-Sa: 02:00 - 10:00

into:

Col_monday: 1: 03:00 - 11:00 | 2: 02:00 - 10:00

Col_tuesday: 1: 03:00 - 11:00 | 2: 02:00 - 10:00

...

How i can get this in Dataprep?

I also have some values in the col1 like "Mo-Fr". And then de Col_saturday has a different columns as source than the showed example (e.g.: Col_openingHours2).

I tried convert values to Columns, but it seems like the wrong tool.

Then i tried to create new columns like col_monday and wanted to set the values with "If(equal (col-openingHours, "Mo-Sa"), ... ) .. (For this i splitted the cell [Mo-Sa |split| 03:00 - 11:00])

But that wasnt the right tool, too i think.

would be very happy for helping me :)

1 Answers1

0

The most straightforward way to handle this would be to turn your openingHours column into a quick JSON object, so you'd have something like


    {
        "1": [{
            "Mon": "03:00 - 11:00",
            "Tues": "03:00 - 11:00",
            "Weds": "03:00 - 11:00"
        }],
        "2": [{
            "Mon": "02:00 - 10:00",
            "Tues": "02:00 - 10:00",
            "Weds": "02:00 - 10:00"
        }]
    }

This should be achievable by using text pattern replacements and a bit of regex as needed. Once that's done, you can unnest the data itself into columns as you desire, now with the right splits per value.

Casey Grimes
  • 117
  • 12