This following code sample will guide you on how to convert a tab delimited text file to JSON format, with the following JSON file structure, using of Python programming.

First, let create a text file with tab delimited as following:

Save the file as employee.txt

Now, create a .py file with the following python code:

Save the file as text2json.py

To execute text2json.py, run it using the python command as following:

python text2json.py
A new json file called emp.json should be created now with the following content.

Download sample source code: txt2json.zip