Search code examples
orange

Flatten data in a table which has a field with mulitple values


My csv table looks like this:

class, duration, rooms
"Engine Drawing", 30, "eng010, eng201"
"Linear Systems", 30, "eng110"
"Linear Algebra", 24, "mat015, art603, hum202"

I'd like to flatten it out to this form:

class, duration, room
"Engine Drawing", 30, "eng010"
"Engine Drawing", 30, "eng201"
"Linear Systems", 30, "eng110"
"Linear Algebra", 24, "mat015"
"Linear Algebra", 24, "art603"
"Linear Algebra", 24, "hum202"

It's a simple enough transformation, duplicating row for each value in comma delimited field.

Is there a way to do this in Orange without resporting to code?


Solution

  • If you go to the .tab format, you can mark the last column as basket; see http://docs.orange.biolab.si/reference/rst/Orange.data.formats.html#baskets. In this way you will load the last column as a list of values, not a single value -- don't forget to remove the quotes.

    But from the on you're on you own. There's no such flattening in Orange, you'll have to code it. It shouldn't be more than a few lines.