Python: Convert CSV to JSON format
Mohamad's interest is in Programming (Mobile, Web, Database and Machine Learning). He is studying at the Center For Artificial Intelligence Technology (CAIT), Universiti Kebangsaan Malaysia (UKM).
import pandas as pd
# Load the dataset
dset_url = 'https://archive.org/download/misc-dataset/airline-tweets.csv'
df_airline = pd.read_csv(dset_url)
# Convert the DataFrame to JSON format
json_data = df_airline.to_json(orient='records', lines=True)
# Save the JSON data to a file
with open('airline_tweets.json', 'w') as json_file:
json_file.write(json_data)
print("JSON data has been saved to airline_tweets.json")