I try to convert from json to csv, But there is Extra letter "u" has been appeared before every word in list , i used pandas to read this csv data, this is my code :
import json
import csv
with open("train.json") as file:
data = json.load(file)
with open("trainc.csv", "w") as file:
csv_file = csv.writer(file)
csv_file.writerow(data[0].keys())
for item in data:
csv_file.writerow(item.values())
import pandas as pd
train = pd.read_csv("trainc.csv", header=0)
As Example from json file, this is the first one :
{
"id": 10259,
"cuisine": "greek",
"ingredients": [
"romaine lettuce",
"black olives",
"grape tomatoes",
"garlic",
"pepper",
"purple onion",
"seasoning",
"garbanzo beans",
"feta cheese crumbles"
]
}
I used this line to print ingredients
print train['ingredients'][0]
And when I printed the same record output was like that :
[u'romaine lettuce', u'black olives', u'grape tomatoes', u'garlic', u'pepper', u'purple onion', u'seasoning', u'garbanzo beans', u'feta cheese crumbles']