I have a csv with my data that I turn into a JSON and then provide it as initial data for my Django Model.
Whenever I run
python manage.py migrate
I get
raise ValueError(errmsg("Extra data", s, end, len(s))) django.core.serializers.base.DeserializationError: Problem installing fixture 'PATH TO FOLDER/initial_data.json': Extra data: line 2 column 1 - line 666 column 643 (char 729 - 498863)
Line 666 column 643 is the last character in my JSON. Also even if cut the JSON in half it will still say the error is on the last character.
My code to turn the CSV into a JSON is:
import csv
import json
csvfile = open('organizationTest1.csv', 'rU')
jsonfile = open('initial_data.json', 'w')
fieldnames = ("role","name")
reader = csv.DictReader( csvfile, fieldnames)
a = 0
for row in reader:
a += 1
json.dump(row, jsonfile)
jsonfile.write('\n')
If anyone knows why this is happening or how I could fix it I would love to know. Also if you have any questions I would be happy to answer them!