GH avatar Bite 150. Turn messy CSV into JSON

At the 1 year mark of our platform here is Bite 150! In this Bite you are presented with some messed up csv (to avoid file IO we pre-loaded it into a multi-line string variable members). The first line is the header and can be assumed to only have commas, the 10 data rows though have a mix of ,, | and ; delimiters.

But no worries, you Python ninjas can do data cleaning for breakfast no?!

Complete convert_to_json parsing this output and returning valid json like this:

{'id': '1', 'first_name': 'Junie', 'last_name': 'Kybert', 'email': '[email protected]'}
{'id': '2', 'first_name': 'Sid', 'last_name': 'Churching', 'email': '[email protected]'}
{'id': '3', 'first_name': 'Cherry', 'last_name': 'Dudbridge', 'email': '[email protected]'}
...
...

The tests will check if your output is indeed valid json and of course if it contains all data. Good luck!

Login and get coding
go back Intermediate level
Bitecoin 3X

73 out of 74 users completed this Bite.
Will you be Pythonista #74 to crack this Bite?
Resolution time: ~47 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 4.2 on a 1-10 difficulty scale.
» Up for a challenge? 💪

We use Python 3.7