On Wed, Mar 7, 2012 at 11:36 PM, Steven D'Aprano <st...@pearwood.info> wrote: > Marko Limbek wrote: > >> I put the recommended code >> >> savFileName = >> "C:/dropbox/Exc_MarkoL_Zenel/Valicon/crosstabs/Tabela/ipk108_kosovo_data_finale_c1-1.sav" >> with SavReader(savFileName) as sav: >> header = sav.next() >> for line in sav: >> process(line) >> >> >> but I am get errors > > > > Will you tell us what errors, or should we just guess? > > Since I love guessing games, let me try... my guess is that you get > > AttributeError: 'SavReader' object has no attribute 'next' > > Am I close? If so, try using next(sav) instead of sav.next().
I overcame commenting. I managed to read my own file and print it. Now I am trying to use method getNumberofVariables() but unsuccesfully. First way SavReader(savFileName).getNumberofVariables() gives me this error Traceback (most recent call last): File "C:\Dropbox\Exc_MarkoL_Zenel\Python\crosstabs\src\src\rw.py", line 660, in <module> SavReader(savFileName).getNumberofVariables() TypeError: getNumberofVariables() takes exactly 3 arguments (1 given) Second way getNumberofVariables(savFileName, fh, spssio) gives me this error Traceback (most recent call last): File "C:\Dropbox\Exc_MarkoL_Zenel\Python\crosstabs\src\src\rw.py", line 660, in <module> getNumberofVariables(savFileName, fh, spssio) NameError: name 'getNumberofVariables' is not defined Why there needs to be fh and spssio? I would like to be able to know how to use all the methods to run and test them and see, if any of them can give me labels from the file instead of just pure numbers, before I start asking questions if there is any method that can read labels. I am really sorry but I tried to find answers to that in the tutorial. I would like to read labels with such characters like čšž and not just read pure numbers. > > >> I have however managed to compile the programme in the module, I just >> had to comment more than 20 lines (because of that problem with >> "employee data.sav" ). >> I also don't know, if it was right to comment all those lines. Without >> commenting them I can't even compile the module. > > > > Marko, it seems that you don't know how to program Python. Perhaps you > should do a Python tutorial or two so you can fix the code instead of just > commenting out lines. > > Perhaps start here: http://docs.python.org/tutorial/ > I have been using Python for a few months now and I am a mathematician, so I have done some programming. It is true however that I am not trained programmer. So please excuse dumb questions. But I have fixed the code so far that I can read and print. Marko _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor