Python Create JSON File

Problem Formulation and Solution Overview This article focuses on working with a JSON file. JSON is an acronym for JavaScript Object Notation. This is a flat-text file formatted based on JavaScript (JS) Syntax. This file is most commonly noted for its ability to transmit data to/from web applications, such as sending/receiving data from a Server/Client … Read more

Python Convert GeoJSON to CSV

What is GeoJSON? 💡 GeoJSON is an RFC standardized data format to encode geographic data structures such as Point, LineString, Polygon, MultiPoint, MultiLineString, and MultiPolygon. GeoJSON is based on the JavaScript Object Notation (JSON). Example GeoJSON to CSV Say, you have the following GeoJSON snippet: You want to convert it to the following CSV format: … Read more

Convert CSV to JSON in Python

5 Easy Steps to Convert a CSV to a JSON File You can convert a CSV file to a JSON file by using the following five steps: Import the csv and json libraries Open the CSV as a file object in reading mode using the open(path_to_csv, ‘r’) function in a context manager (=with environment). Load … Read more

How to Convert JSON to Pandas DataFrame

Problem Formulation and Solution Overview In this article, you’ll learn how to read a JSON string and convert it to a Pandas DataFrame in Python. To make it more fun, we have the following running scenario: Antoine, a Curator from the Smithsonian Museum, is taking their Egyptian Collection on the road. Antoine has received a … Read more

Parse JSON Data in Python

[toc] Problem Formulation Do you have JSON data that you need to parse using a Python script? Let’s have a look at this JSON data – But when you try to parse this file in your script, you get an exception. Frustrating! Isn’t it? Don’t worry. Most probably you have no errors in your script. … Read more

Cómo agregar datos a un archivo JSON en Python [+Vídeo]

Switch to English Version Planteamiento del problema Dado un objeto JSON almacenado en un archivo llamado “your_file.json”, como una lista de diccionarios. ¿Cómo se pueden anexar datos, como un nuevo diccionario? # File “your_file.json” (BEFORE) [{“alice”: 24, “bob”: 27}] # New entry: {“carl”: 33} # File “your_file.json” (AFTER) [{“alice”: 24, “bob”: 27}, {“carl”: 33}] Método … Read more

Python Input/Output – JSON

Over your career as a Data Scientist, there may be instances where you will work with data to/from a DataFrame to JSON format. This article shows you how to manipulate this data using the above functions. This article covers the commonly used parameters for each function listed above. For a complete list of all parameters … Read more

How to Append Data to a JSON File in Python? [+Video]

Problem Formulation Given a JSON object stored in a file named “your_file.json” such as a list of dictionaries. 💬 How to append data such as a new dictionary to it? # File “your_file.json” (BEFORE) [{“alice”: 24, “bob”: 27}] # New entry: {“carl”: 33} # File “your_file.json” (AFTER) [{“alice”: 24, “bob”: 27}, {“carl”: 33}] Method 1: … Read more