For example:
key1: 1,2,3,4
key2: 5,6
will convert to
key1|key2
1|5
2|6
3
4
And I know if we do this iteratively, there a lot of ways which are not efficient. I am wondering if there is any built-in methods or anything which can transform them directly.
HashMap<String, String> h1 = new HashMap<String, String>;
h1.put("key1", "1,2,3,4");
h1.put("key2", "5,6");
need to print out as pipe delimited format:
key1|key2
1|5
2|6
3
4
You can use a class like this one:
Invocation is
String dataset = LegacyGlueifier.generateLegacyDataset(myMap)I ran it through a basic test case to see if it worked but I’d still test it more thoroughly since you’re going to be using it.
Its time complexity is somewhere between linear to the total number of comma delimited fields in the original dataset and linear to the total number of fields in the output dataset (including blank ones).