There's this video that I have been referencing where I am trying to recreate the the idea into a python script. I feel like I am on the right path but there is definitely something I am missing. Instead of one cohesive curve, my curve data seems to be creating multiple splines, but it seems like it's suppose to be just one based on the video. Any idea what I am doing wrong?
Current Code
import requests, json, bpy
data = requests.get("https://www.econdb.com/api/series/PPIUS/?format=json").json()
values = data['data']['values']
dates = data['data']['dates']
pairs = [[value, date] for value, date in zip(values, dates)]
bpy.data.curves.new(name='curve_data',type='CURVE')
curve = bpy.data.curves['curve_data']
curve.dimensions = "3D"
curve.resolution_u = 2
bezzy = curve.splines.new("BEZIER")
bezzy.bezier_points.add(len(pairs))
for index, pair in enumerate(pairs):
value, date = pair
bezzy.bezier_points[index].co = (index, 0, value)
new_curve = bpy.data.objects.new("my_curve", curve)
collection = bpy.context.collection
collection.objects.link(new_curve)
bpy.context.view_layer.objects.active = new_curve
#new_curve.select = True
print(bezzy.points, new_curve)