# Assuming there is a file a.csv in current folder with below content # name,year # Rana,1989 # Python,1995 python3 -c "import csv,json;print(json.dumps(dict(csv.reader(open('a.csv')))))" # output # {"name": "year", "Rana": "1989", "Python": "1995"}