Skip to content
Advertisement

How to convert string of list of list to list?

I have this file, it is the result of the MapReduce job so it has key-value format:

JavaScript

I want to remove all the character except the second element of this value list:

JavaScript

And finally, add each to a single list:

JavaScript

This is my attempt so far:

JavaScript

Output:

JavaScript

You can see it is still str type, how can I make it to list type?

Advertisement

Answer

Treat it as a line of json and just replace parts of your lines with json documents as needed

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement