Error help

danielashiloh at googlemail.com danielashiloh at googlemail.com
Thu Aug 2 06:58:20 EDT 2012


Hi all

This error has been bugging me for days. I know it's minor, but it's really getting in the way of my programming. I'm programming a data analysis programme for a psychology experiment which takes pickled data from the experiment and produces averages. For some reason python is insisting there is an indentation error on line 18. I have untabified and retabified and nothing seems to work. Here is the full code:


import cPickle, pickle

print 'WELLCOME TO THE LIBET CLOCK EXPERIMENT DATA ANALYSIST'
file=raw_input('\nPLEASE ENTER THE NAME OF THE FILE YOU WISH TO ANALYSE: ')
pickle_file=open(file, 'r')
data=cPickle.load(pickle_file)
file_name=file-'pck' + 'txt'
partifipant_info=data'Participant Info']
first_block_data=data['First block data']
second_block_data=data['Second block data']
first_block_estimates=first_block_data['Estimated times']
first_block_times=first_block_data['Actual times']
second_block_estimates=second_block_data['Estimated times']
second_block_times=second_block_data['Actual times']


def firstBlockDifferences():
    print '\nCALCULATING AVERAGE DIFFERENCES FOR BLOCK 1' 
    count=0
    first_block_differences=[]
    total=0
    while count<len(first_block_estimates):
        differences=float(first_block_estimates[count])-float(first_block_times[count])
        if differences >= 180:
            differences-=360
        elif differences <=-180:
            differences+=360
        total+=differences
        differences=[differences]
        first_block_differences+=differences
        count+=1
    average_diff_first_block=total/len(first_block_estimates)
    text_file.write('\nAverage differences for block 1: ', average_diff_first_block)

def secondBlockDifferences():
    print '\nCALCULATING AVERAGE DIFFERENCES FOR BLOCK 2'
    count=0
    second_block_differences=[]
    total=0
    while count<len(second_block_estimates):
        differences=float(second_block_estimates[count])-float(second_block_times[count])
        if differences >= 180:
            differences-=360
        elif differences <=-180:
            differences+=360
        total+=differences
        differences=[differences]
        second_block_differences+=differences
        count+=1
    average_diff_second_block=total/len(second_block_estimates)
    text_file.write('\nAverage differences for block 2: ', average_diff_second_block)


text_file=open(file_name, 'w')
text_file.write('\nParticipant info: ', participant_info)
firstBlockDifferences()
secondBlockDifferences()

I apologise for the lack of annotation and it may be a little inefficient, but I am really only after a solution to the error on line 18.

Thanks.



More information about the Python-list mailing list