AttributeError when adding keyframes in draw function
The draw function is for UI only (defining layout and visibility of properties, sliders etc). It's called multiple times per second, sometimes 20 or more times, as you move your mouse around

You can't change bpy.data (including keyframes) from inside draw, it is blocked by design. You probably don't want to repeatedly execute that code anyway. A standard approach is to Run it from Text Editor with or without an enclosing function.

If this represents the first and second line of the the dataset, and the next lines are all formatted like line 2.

dataset.txt

GYROSCOPE X (°/s);GYROSCOPE Y (°/s);GYROSCOPE Z (°/s);Time since start in ms ;YYYY-MO-DD HH-MI-SS_SSS
9.08;-1.04;-9.51;20;2015-07-03 14:17:34:206


code

import csv
import bpy

def some_function(fp):

    obj = bpy.data.objects['Camera']

    results = []
    with open(fp, newline='') as inputfile:
        row_gen = csv.reader(inputfile)
        next(row_gen) # skip first line.

        for row in row_gen:
            results.append(row[0].split(';'))

    # start making frames at frame 1
    for idx, frame_data in enumerate(results, 1):
        xRot, yRot, zRot = frame_data[:3]
        print(xRot, yRot, zRot)
        obj.rotation_euler[0] += float(xRot)
        obj.rotation_euler[1] += float(yRot)
        obj.rotation_euler[2] += float(zRot)
        obj.keyframe_insert(data_path="rotation_euler", frame=idx, index=-1)

some_function(fp='/home/zeffii/Desktop/zen/dataset.txt')


The -1 at the end indicates that the keyframe is to be added after the other existing keyframes.



For info about paths; whether to use back or forward slashes, see:   


  https://blender.stackexchange.com/tags/path/info  


Adding this for completeness, because it differs across Operating Systems.