# How can I animate data using blender python?

I have imported data from Matlab and want to use this to animate the rotations of two objects that I have already created in the scene. The loop I have created does not end up changing the object's rotational orientation on each keyframe; the animation is static and the objects do not move at all. If someone could point out an error in my code or my approach that would be greatly appreciated.

import bpy

from math import *
from mathutils import *
import numpy as np

ob1 = bpy.data.objects['Retriever']
ob2 = bpy.data.objects['defectsatellite']
bpy.context.scene.objects.active = ob1
bpy.context.scene.objects.active = ob2

#Import the data from matlab "Equation Analysis" script
rot1 = []
rot2 = []

for i in x1:
rot1.append(i)

for i in x2:
rot2.append(i)

#Set up key frames, controlling the rotation of each satellite.

#First extract every fifth row
def altelement(x):
return x[::10]

rot1 = altelement(rot1)
rot2 = altelement(rot2)

sce = bpy.context.scene
bpy.ops.screen.frame_jump(end=False)
frame_num = 0

for j in range(0,len(rot2)):

bpy.context.scene.frame_set(frame_num)
ob1.rotation_euler.x = (rot1[j])
ob2.rotation_euler.x = (rot2[j])
sce.update()
ob1.keyframe_insert(data_path = "location", index = -1)
ob2.keyframe_insert(data_path = "location", index = -1)
frame_num += 1


ob1.keyframe_insert(data_path = "rotation_euler", index = -1)