Re: [Tutor] Hello everybody
On Mon, Jun 13, 2016 at 11:55 PM, Влад <79099012...@yandex.ru> wrote: >Hi. I've just begin with Python? I'm 34. Is it late or what? If it is - > I >will cut it out. What you think guys? >** > Here myself 48 crossed, just started taking python step by step Welcome to the herd >--** >** **, >, PR- Rich PR >+79099012930 >** > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Python ODBC driver for Oracle 9
Hi All, I am trying to connect Python to Oracle 9 DB, checked for python ODBC driver for oracle. What I could find point out to http://cx-oracle.sourceforge.net/ , but this driver supports from Oracle 11 on wards. What I need is driver for Pyhton to get connected to Oracle 9. Did lots of google search, did not find any proper links which is leadeing to the Oracle9i driver. And now I am trying to post here to get advice or url on how to get oracle 9 python driver. Thanks Joseph John ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Command statement work well on interactive mode, which running as pf file it throws error object has no attribute '__getitem__'
On Thu, Jun 9, 2016 at 12:49 PM, Joseph John <jjk.s...@gmail.com> wrote: > > > On Thu, Jun 9, 2016 at 12:07 PM, Alan Gauld via Tutor <tutor@python.org> > wrote: > >> On 09/06/16 08:33, Joseph John wrote: >> >> > Now when I create a *.py file with all the above steps and run it, I am >> > getting error >> > Traceback (most recent call last): >> > File "./ReadingDataFrom1X.py", line 10, in >> > c = sheet['A1'] >> > TypeError: 'Worksheet' object has no attribute '__getitem__' >> > >> > >> > The contents of “ReadingDataFrom1X.py” is as follows >> > #!/usr/bin/python >> > import openpyxl >> > wb = openpyxl.load_workbook('MyTutor.xlsx') >> > wb.get_sheet_names() >> > sheet= wb.get_sheet_by_name('SQL Results') >> > sheet.title >> > print sheet.title >> > print sheet['A1'] >> >> Not according to the error message. It says the error >> is on the line: >> >> c = sheet['A1'] >> >> But you don't have such a line. >> >> So the code you sent us is not the code you are running. >> Why that may be is the puzzle. >> Do you have more than one file called ReadingDataFrom1X.py? >> >> How are you running the code? Is it from an IDE such as IDLE? >> Or from the OS command line? That might make a difference. >> >> Hi Alan, > Thanks for the reply. > I have only the same file, what happened is that I was editing the file in > a editor for troubleshooting and when I run the file it was not saved, I > was trimming the code to the minimum > Now the program file has only the > #!/usr/bin/python > import openpyxl > wb = openpyxl.load_workbook('MyTutor.xlsx') > wb.get_sheet_names() > sheet= wb.get_sheet_by_name('SQL Results') > sheet.title > print sheet.title > print sheet['A1'] > > and when I run it from the command line, it gets this error > Traceback (most recent call last): > File "./ReadingDataFrom1X.py", line 8, in > print sheet['A1'] > TypeError: 'Worksheet' object has no attribute '__getitem__' > > I also suspect that my user python installation has issues. I will test > it > I will test it on another user environment and see how it comes and give > the feedback on a separate thread > > Tired it on a fresh install of Ubuntu 14.04 64 bit , Python version 2.7.6 Same error I am getting File "./ReadingDataFrom1X.py", line 8, in print sheet['A1'] TypeError: 'Worksheet' object has no attribute '__getitem__ for the code itsupport@Server-A:~$ cat ReadingDataFrom1X.py #!/usr/bin/python import openpyxl wb = openpyxl.load_workbook('1XDataUserMDN.xlsx') wb.get_sheet_names() sheet= wb.get_sheet_by_name('SQL Results') sheet.title print sheet.title print sheet['A1'] #sheet['A1'].value #c = sheet['A1'] #'The user id is ' + c.value Thanks Joseph John > Thanks a lot > Joseph John > > > >> >> >> -- >> Alan G >> Author of the Learn to Program web site >> http://www.alan-g.me.uk/ >> http://www.amazon.com/author/alan_gauld >> Follow my photo-blog on Flickr at: >> http://www.flickr.com/photos/alangauldphotos >> >> >> ___ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> https://mail.python.org/mailman/listinfo/tutor >> > > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Command statement work well on interactive mode, which running as pf file it throws error object has no attribute '__getitem__'
On Thu, Jun 9, 2016 at 12:07 PM, Alan Gauld via Tutor <tutor@python.org> wrote: > On 09/06/16 08:33, Joseph John wrote: > > > Now when I create a *.py file with all the above steps and run it, I am > > getting error > > Traceback (most recent call last): > > File "./ReadingDataFrom1X.py", line 10, in > > c = sheet['A1'] > > TypeError: 'Worksheet' object has no attribute '__getitem__' > > > > > > The contents of “ReadingDataFrom1X.py” is as follows > > #!/usr/bin/python > > import openpyxl > > wb = openpyxl.load_workbook('MyTutor.xlsx') > > wb.get_sheet_names() > > sheet= wb.get_sheet_by_name('SQL Results') > > sheet.title > > print sheet.title > > print sheet['A1'] > > Not according to the error message. It says the error > is on the line: > > c = sheet['A1'] > > But you don't have such a line. > > So the code you sent us is not the code you are running. > Why that may be is the puzzle. > Do you have more than one file called ReadingDataFrom1X.py? > > How are you running the code? Is it from an IDE such as IDLE? > Or from the OS command line? That might make a difference. > > Hi Alan, Thanks for the reply. I have only the same file, what happened is that I was editing the file in a editor for troubleshooting and when I run the file it was not saved, I was trimming the code to the minimum Now the program file has only the #!/usr/bin/python import openpyxl wb = openpyxl.load_workbook('MyTutor.xlsx') wb.get_sheet_names() sheet= wb.get_sheet_by_name('SQL Results') sheet.title print sheet.title print sheet['A1'] and when I run it from the command line, it gets this error Traceback (most recent call last): File "./ReadingDataFrom1X.py", line 8, in print sheet['A1'] TypeError: 'Worksheet' object has no attribute '__getitem__' I also suspect that my user python installation has issues. I will test it I will test it on another user environment and see how it comes and give the feedback on a separate thread Thanks a lot Joseph John > > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Command statement work well on interactive mode, which running as pf file it throws error object has no attribute '__getitem__'
Dear All, I am taking my initial steps to interact Python with excel files. I was success in importing the needed modules, and executing steps in interactive mode . All my initial commands such as import openpyxl wb = openpyxl.load_workbook('MyTutor.xlsx') wb.get_sheet_names() sheet= wb.get_sheet_by_name('SQL Results') sheet.title print sheet.title print sheet['A1'] All worked fine Now when I create a *.py file with all the above steps and run it, I am getting error Traceback (most recent call last): File "./ReadingDataFrom1X.py", line 10, in c = sheet['A1'] TypeError: 'Worksheet' object has no attribute '__getitem__' The contents of “ReadingDataFrom1X.py” is as follows #!/usr/bin/python import openpyxl wb = openpyxl.load_workbook('MyTutor.xlsx') wb.get_sheet_names() sheet= wb.get_sheet_by_name('SQL Results') sheet.title print sheet.title print sheet['A1'] If the statement worked in the interactive mode, it should all work while executing the file created. Did some google search, did not come across any valid reason why the error message is showing. Would like to request for guidance and feed back, please let me know why all my command statements work on interactive mode and when I run it in a py file some commands throws error Thanks Joseph John ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] import openpyxl throws error in-spite I have python-openpyxl installed.
Like to give the status I have messed up my Python installation, now I remember there was the default python installation from the OS installed and "Canopy" version which I had setup in my home directories. Because of this reason import openpyxl was not working for the shell ( I tested it by logging in as another user) In my my user space,I solved it by giving pip install openpyxl Thanks Joseph John On Thu, Jun 9, 2016 at 8:51 AM, Joseph John <jjk.s...@gmail.com> wrote: > Hi All, > I am trying to explore python, trying to read from excel file. > I am using Ubuntu 16.04 > As a first step I mae sure that I have the package installed > “python-openpyxl” > Now in the python command line when I tried to import openpyxl it throws > error. > >>> import openpyxl > Traceback (most recent call last): > File "", line 1, in > ImportError: No module named openpyxl > >>> > My environment are > OS Ubuntu 14.04 LTS > Python 2.7.9 -- 64-bit > python-openpyxl version 1.7.0+ds1-1 > > I am not able to find why the system throws error when I am importing > openpyxl, since I have python-openpyxl installed. > > Like to request guidance and feedback > Thanks > Joseph John > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] import openpyxl throws error in-spite I have python-openpyxl installed.
Hi All, I am trying to explore python, trying to read from excel file. I am using Ubuntu 16.04 As a first step I mae sure that I have the package installed “python-openpyxl” Now in the python command line when I tried to import openpyxl it throws error. >>> import openpyxl Traceback (most recent call last): File "", line 1, in ImportError: No module named openpyxl >>> My environment are OS Ubuntu 14.04 LTS Python 2.7.9 -- 64-bit python-openpyxl version 1.7.0+ds1-1 I am not able to find why the system throws error when I am importing openpyxl, since I have python-openpyxl installed. Like to request guidance and feedback Thanks Joseph John ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Finding the latest file in a dir
Hi All, Even though I am a old user in the mailing list, my skills in Python are not impressive. I have restarted doing python for some small task. I am trying to find the latest file in a dir, I have searched and found out I shoulld do in this way #!/usr/bin/python import os newest = max(os.listdir(/opt/AlfDB/.), key = os.path.getctime) print newest --- but when I run it I am getting error message such as ./FindingLatestFileInDir.py Traceback (most recent call last): File ./FindingLatestFileInDir.py, line 4, in module newest = max(os.listdir(/opt/AlfDB/.), key = os.path.getctime) File /usr/lib64/python2.7/genericpath.py, line 64, in getctime return os.stat(filename).st_ctime OSError: [Errno 2] No such file or directory: 'alfresco20140104-.sql' -- I get results if I do it without giving the dir location such as --- #!/usr/bin/python import os newest = max(os.listdir(.), key = os.path.getctime) print newest - This gives the result for the directory from where it runs, but when I change the dir location to /opt/AlfDB , It does not. I am not able to apprehend how it is not working Guidance and advice requested Thanks Joseph John ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] How to copy file from a source, I do not know the source file name, Only path to the src directory I know
Hi All I am trying our Python . My aim is to copy a file to a location and later removing the file.I had written a small script which works.It works only if I specify the source file name. I would like to make it work in a scenario in which I do not know the name of the source file(the source directory will have only one file at any time) I am posting the script which I have done,How to modify the script to copy the source file even if I do not know the name of the file my script is below ### #!/usr/bin/python # This script aims to copy file from one directoy to anothe and later removing the files # This script works when I know the source file name, I want to this script to function even if I do not know the name of # the file in /home/joseph/Projects/Training/Python/example/One/ import shutil # FromOne is a file in /home/joseph/Projects/Training/Python/example/One/ src = /home/joseph/Projects/Training/Python/example/One/FromOne # dst2 = /home/joseph/Projects/Training/Python/example/Two/ dst3 = /home/joseph/Projects/Training/Python/example/Three/ # # #shutil.move(src, dst) shutil.copy(src,dst2) shutil.move(src,dst3) ## -- Thanks Joseph John http://www.oss101.com/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to copy file from a source, I do not know the source file name, Only path to the src directory I know
Thanks I was able to solve it by dirList=os.listdir(src) for fname in dirList: print fname ffname = '/home/joseph/Projects/Training/Python/example/One/'+fname print ffname #shutil.copy(ffname,dst2) shutil.move(ffname,dst3) On Tue, Nov 9, 2010 at 4:38 PM, Evert Rol evert@gmail.com wrote: Hi All I am trying our Python . My aim is to copy a file to a location and later removing the file.I had written a small script which works.It works only if I specify the source file name. I would like to make it work in a scenario in which I do not know the name of the source file(the source directory will have only one file at any time) Have a look at the os module, specifically os.listdir() The glob module could also be handy. Cheers, Evert I am posting the script which I have done,How to modify the script to copy the source file even if I do not know the name of the file my script is below ### #!/usr/bin/python # This script aims to copy file from one directoy to anothe and later removing the files # This script works when I know the source file name, I want to this script to function even if I do not know the name of # the file in /home/joseph/Projects/Training/Python/example/One/ import shutil # FromOne is a file in /home/joseph/Projects/Training/Python/example/One/ src = /home/joseph/Projects/Training/Python/example/One/FromOne # dst2 = /home/joseph/Projects/Training/Python/example/Two/ dst3 = /home/joseph/Projects/Training/Python/example/Three/ # # #shutil.move(src, dst) shutil.copy(src,dst2) shutil.move(src,dst3) ## -- Thanks Joseph John http://www.oss101.com/ ___ Tutor maillist - tu...@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Thanks Joseph John http://www.oss101.com/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Integer division Help requested
HI All I am trying out python I understoon when 7/3 gives 2But I cannot understand , when i give 7/-3 gives resuls -3I feel 7/3 should give -2 since integer divison returns floor Advice requested Thanks Joseph John ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor