Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Convert JSON to CSV

import json
if __name__ == '__main__':
    try:
        with open('input.json', 'r') as f:
            data = json.loads(f.read())

        output = ','.join([*data[0]])
        for obj in data:
            output += f'
{obj["Name"]},{obj["age"]},{obj["birthyear"]}'
            
        with open('output.csv', 'w') as f:
            f.write(output)
    except Exception as ex:
        print(f'Error: {str(ex)}')
Source by codingblog.online #
 
PREVIOUS NEXT
Tagged: #Convert #JSON #CSV
ADD COMMENT
Topic
Name
9+9 =