How do I modify this script to affect bones instead of shape keys? import bpy
import csv
import numpy as np
data_path = 'C:/Users/E/Desktop/example.csv'
ob = bpy.context.object

with open(data_path, 'r') as f:
    reader = csv.reader(f, delimiter=',')
    names = next(reader)
    data = np.array(list(reader))
shapekeys = ob.data.shape_keys.key_blocks
for i in range(data.shape[0]):
    if data[i][1] != '0':
        
        for shape in shapekeys:
            if shape.name in names:
                index = names.index(shape.name)
                shape.value=float(data[i][index])                
                shape.keyframe_insert(&quot;value&quot;, frame=i)

# The script does all the data mining to get the needed values. 
# It allocates 3 values needed to utilize
# shape.name = bone name
# shape.value = location Y
# current frame = i
# I added these lines below but it doesn't work
    
    pb = ob.pose.bones.get(shape.name)
    if pb:
        pb.location.y = shape.value
        pb.keyframe_insert(&quot;location&quot;, i ) # y location

This script gives me an error
&quot;armature object has no attribute&quot;
So what is it that is needed to make this script allocate bone values locations Y?
Something like?
Speculating that the data file is akin to
name value
Bone 10.0
Bone.001 22

and using a string to emulate the file, ie data.splitlines() to emulate a text file buffer. Example below, pose bone &quot;Bone&quot; keyframe location 0 at frame 0,
Run script  with the armature object active and not in edit mode.
import bpy
import csv 

context = bpy.context
ob = context.object
frames_per_line = 20

data = '''Bone, 0
Bone.001, 0.4
Bone.002,  1.0
Bone, 10
Bone, 20
Bone.002, -2.9'''

for frame, (name, value) in enumerate(csv.reader(data.splitlines())):

    pb = ob.pose.bones.get(name)
    if pb:
        pb.location.y = float(value)
        pb.keyframe_insert(
                &quot;location&quot;,
                 index=1,
                 frame=frames_per_line * frame
             ) # y location