On 08/02/2012 06:58 AM, danielashi...@googlemail.com wrote: > 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.
You didn't include the error message, so how are we supposed to know which line is #18 ? if I take your message literally, it's a blank line. Even better, you could have reduced the code down to a minimum which still shows the error. As your code stands now, I get an error on line 10: File "daniel.py", line 10 partifipant_info=data'Participant Info'] ^ SyntaxError: invalid syntax It appears you're missing a left bracket. That line also has a strange spelling for participant, so you'd get an error later when you tried to use participant_info. Did you by any chance retype your program into the message? If you don't use copy/paste, it's useless for us to study your code. Finally, in case it matters, just what version of python did you use, and on what OS? -- DaveA -- http://mail.python.org/mailman/listinfo/python-list