Logical Query JSON

2015-07-30 Thread subhabrata . banerji
Dear Group, 

I am trying to query JSON with Logical operators. 

I tried to experiment lot with it, but could not do much. 
I came many times pretty close but missed it almost. 

I tried to experiment with json, jsonquery, jsonschema, jsonpipe, objectpath, 
requests. 

I got a good example from 
http://www-01.ibm.com/support/knowledgecenter/SSEPEK_11.0.0/com.ibm.db2z11.doc.json/src/tpc/db2z_jsonlogicaloperators.dita
 

But I was looking for one or two worked out examples to start with. 

I am using Python2.7+ on Windows 7 with IDLE as GUI. 

I am trying and if anybody of the esteemed members may kindly help me with. 

  

Regards, 
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Logical Query in Python

2015-07-30 Thread subhabrata . banerji
Dear Group,

I am trying to query JSON with Logical operators. 

I tried to experiment lot with it, but could not do much. 
I came many times pretty close but missed it almost. 

I tried to experiment with json, jsonquery, jsonschema, jsonpipe, objectpath, 
requests. 

I got a good example from 
http://www-01.ibm.com/support/knowledgecenter/SSEPEK_11.0.0/com.ibm.db2z11.doc.json/src/tpc/db2z_jsonlogicaloperators.dita

But I was looking for one or two worked out examples to start with. 

I am using Python2.7+ on Windows 7 with IDLE as GUI. 

I am trying and if anybody of the esteemed members may kindly help me with.

 

Regards,
Subhabrata Banerjee. 


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Logical Query JSON

2015-07-30 Thread subhabrata . banerji
On Thursday, July 30, 2015 at 9:20:35 PM UTC+5:30, Denis McMahon wrote:
 On Thu, 30 Jul 2015 06:32:01 -0700, subhabrata.banerji wrote:
 
  I am trying to query JSON with Logical operators.
 
 Your post was an excellent example of asking for help without explaining 
 what your problem was at all.
 
 Please:
 
 - show an example of what you tried;
 
 - give the results you expected;
 
 - show the results you actually got.
 
 COPY and PASTE the code and results, do not re-type them, or summarise
 them.
 
 I found the examples quite easy to follow to create json queries, 
 although as I don't have a db2 etc setup here iI'm unale to try feeding 
 the resulting json query into a database to see what comes out.
 
 -- 
 Denis McMahon

Dear Sir,

I am trying to quote some of my exercises below, and my objective.

(1) Exercise with objectpath: 
 from objectpath import *
 tree=Tree({a:1})
 tree.execute($.a)
1
 $
{
  a:1,
  b:{
c:[1,2,3]
  }
}
SyntaxError: invalid syntax
 x1={a:1,b:{c:[1,2,3]}}
 x1.b

Traceback (most recent call last):
  File pyshell#46, line 1, in module
x1.b
AttributeError: 'dict' object has no attribute 'b'
 x1.b
SyntaxError: invalid syntax

(2) Exercise from IBM Example:

 x1={or:[{age:4},{name:Joe}]}
 x2=x1
 print x2
{'or': [{'age': 4}, {'name': 'Joe'}]}
 x1['age']

Traceback (most recent call last):
  File pyshell#27, line 1, in module
x1['age']
KeyError: 'age'
 x1['or']
[{'age': 4}, {'name': 'Joe'}]
 x1['or']['age']

Traceback (most recent call last):
  File pyshell#29, line 1, in module
x1['or']['age']
TypeError: list indices must be integers, not str
 x1['or'][0]
{'age': 4}
 x1['or'][1]
{'name': 'Joe'}


My expectation is:

If I do AND, NOT, OR with two or more JSON values like
{age:4}, {name:Joe}, ...etc. then I should get recirprocal
results.
Considering each one as Python variable and applying logical Python
operation helps, but I am looking a smarter solution. 

Apology for indentation error. 

Regards,
Subhabrata Banerjee. 





-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Logical Query in Python

2015-07-30 Thread subhabrata . banerji
On Thursday, July 30, 2015 at 8:35:08 PM UTC+5:30, Steven D'Aprano wrote:
 On Thu, 30 Jul 2015 11:28 pm,  wrote:
 
  Dear Group,
  
  I am trying to query JSON with Logical operators.
 
 What does that mean?
 
  I tried to experiment lot with it, but could not do much.
  I came many times pretty close but missed it almost.
 
 Please:
 
 - show an example of what you tried;
 
 - give the results you expected;
 
 - show the results you actually got.
 
 COPY and PASTE the code and results, do not re-type them, or summarise them.
 
 
 
 
 -- 
 Steven

Dear Sir,

I redrafted it and reposted the question. This post I tried to drop but some 
how came. Please ignore this post. My reposting is with JSON. 

Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


How may I learn Python Web Frameworks

2015-07-24 Thread subhabrata . banerji
Dear Group,

I am slightly new in Python Web Frameworks. I could learn bit of Django, Flask 
and Bottle. 
But I am looking for a good web based tutorial like Python or NLTK. 
Somehow, I did not find documentations for web frameworks are very good, one 
has to do lot of experiments even to learn basic things.
 
I am looking for a good book like Dive into Python or some good web based 
tutorials. 

I tried to search but unfortunately could not find. 

I am using Python2.7+ on Windows 7. 

If any one of the members may kindly suggest.

Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Search in Flask Restful

2015-07-23 Thread subhabrata . banerji
Dear Group,

I am trying to build one REST framework using Restful Flask. 
To put or get I am trying to use the requests module, as 
given in the following lines.

 var2=requests.put('http://127.0.0.1:5000/todos/todo1', data={'task': 'It is 
 my challenge'})
 var3=requests.get('http://127.0.0.1:5000/todos/todo1')

Now I like to search plain as well as Boolean over this Rest.

If I could understand the problem fine, the exercises are given 
in the following URL.

http://flask-restless.readthedocs.org/en/latest/searchformat.html#examples

But I am looking for examples with requests. I searched for help with requests 
in http://docs.python-requests.org/en/latest/, it did not help much.

If anyone of the esteemed members may kindly suggest.

I am using Python2.7+ on Windows 7. Apology for any indentation error. 


Regards,
Subhabrata Banerjee
-- 
https://mail.python.org/mailman/listinfo/python-list


File Upload in Restful Flask

2015-07-20 Thread subhabrata . banerji
Dear Group,

I am trying to learn Rest framework through Restful Flask. 
My initial exercises went fine with 
https://flask-restful.readthedocs.org/en/0.3.3/quickstart.html

Now I want to upload file through Restful Flask. I tried to check the web for 
reference. 
I got these urls, 
(i) 
http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file
(ii) http://stackoverflow.com/questions/28982974/flask-restful-upload-image
(iii) http://blog.luisrei.com/articles/flaskrest.html

But the question I am stuck with what are the things I have to change in the 
example of quickstart tutorial so that I may be able to upload file. Or if any 
one may kindly suggest with a small example. 

If any one of the esteemed members may kindly suggest. 

Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: File Upload in Restful Flask

2015-07-20 Thread subhabrata . banerji
On Monday, July 20, 2015 at 4:40:09 PM UTC+5:30, Simmo wrote:
 On 20/07/2015 11:13, wrote:
  Dear Group,
 
  I am trying to learn Rest framework through Restful Flask.
  My initial exercises went fine with 
  https://flask-restful.readthedocs.org/en/0.3.3/quickstart.html
 
  Now I want to upload file through Restful Flask. I tried to check the web 
  for reference.
  I got these urls,
  (i) 
  http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file
  (ii) http://stackoverflow.com/questions/28982974/flask-restful-upload-image
  (iii) http://blog.luisrei.com/articles/flaskrest.html
 
  But the question I am stuck with what are the things I have to change in 
  the example of quickstart tutorial so that I may be able to upload file. Or 
  if any one may kindly suggest with a small example.
 
  If any one of the esteemed members may kindly suggest.
 
  Regards,
  Subhabrata Banerjee.
 
 
 I'm no expert on Python or REST but the example
 
url = 'http://httpbin.org/post'
files = {'file': open('report.xls', 'rb')}
 
r = requests.post(url, files=files)
r.text
  ...
 
 seems quite straightforward so I would suggest substituting your URL for 
 'http://httpbin.org' and your file name (possibly with full pathname) 
 for 'report.xls'.
 
 Give it a try and report back...
 
 Steve S

Dear Sir,

Thanks. I could change the quickstart api.py slightly. I ran your suggestion
on it. Some result seems coming but I may have to improve some portion, I am 
not getting. Please see the same.

 import requests
 url='http://127.0.0.1:5000/toworks/post'
 files = {'file': open('C:\Python27\NEWS.txt', 'rb')}
 r = requests.post(url, files=files)
 r.text
u'{\nmessage: Method Not Allowed, \nstatus: 405\n}\n'
 

Regards,
Subhabrata Banerji
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: File Upload in Restful Flask

2015-07-20 Thread subhabrata . banerji
On Monday, July 20, 2015 at 6:39:29 PM UTC+5:30, Simmo wrote:
 On 20/07/2015 12:57, wrote:
  On Monday, July 20, 2015 at 4:40:09 PM UTC+5:30, Simmo wrote:
  On 20/07/2015 11:13, wrote:
  Dear Group,
 
  I am trying to learn Rest framework through Restful Flask.
  My initial exercises went fine with 
  https://flask-restful.readthedocs.org/en/0.3.3/quickstart.html
 
  Now I want to upload file through Restful Flask. I tried to check the web 
  for reference.
  I got these urls,
  (i) 
  http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file
  (ii) 
  http://stackoverflow.com/questions/28982974/flask-restful-upload-image
  (iii) http://blog.luisrei.com/articles/flaskrest.html
 
  But the question I am stuck with what are the things I have to change in 
  the example of quickstart tutorial so that I may be able to upload file. 
  Or if any one may kindly suggest with a small example.
 
  If any one of the esteemed members may kindly suggest.
 
  Regards,
  Subhabrata Banerjee.
 
 
  I'm no expert on Python or REST but the example
 
  url = 'http://httpbin.org/post'
  files = {'file': open('report.xls', 'rb')}
 
  r = requests.post(url, files=files)
  r.text
...
 
  seems quite straightforward so I would suggest substituting your URL for
  'http://httpbin.org' and your file name (possibly with full pathname)
  for 'report.xls'.
 
  Give it a try and report back...
 
  Steve S
 
  Dear Sir,
 
  Thanks. I could change the quickstart api.py slightly. I ran your suggestion
  on it. Some result seems coming but I may have to improve some portion, I 
  am not getting. Please see the same.
 
  import requests
  url='http://127.0.0.1:5000/toworks/post'
  files = {'file': open('C:\Python27\NEWS.txt', 'rb')}
  r = requests.post(url, files=files)
  r.text
  u'{\nmessage: Method Not Allowed, \nstatus: 405\n}\n'
 
 
  Regards,
  Subhabrata Banerji
 
 
 OK, so that message is telling you that whatever server is sitting 
 behind 127.0.0.1 is not allowing you (your code) to POST to it.  There 
 are many reasons why this could be happening.  Here are a couple for you 
 to investigate...
 
 - port 5000 is not not 'open' for POSTs
 - your code may not have permission to POST to the server
 
 It would help if you could tell us what OS you are using (Windows or 
 Linux or ...) and what server is sitting behind 127.0.0.1.
 
 I'n not going to be around for the next 24hrs but I'm sure someone else 
 on the list will have some suggestions for you...
 
 Happy bug hunting
 
 Steve

Dear Sir,

Thanks. I am on MS-Windows 7 and I use mostly Firefox. I am checking other 
issues.

Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Combing Search Engine with REST

2015-07-10 Thread subhabrata . banerji
Dear Group,

I am trying to make a search engine. I used Whoosh to do it. 
I want to add documents to it. This is going fine. 
Now, I want to add documents in the index with REST framework.
I could learn Flask well. 
My task is to use Flask to add documents (by using put/post) to index. 
I am slightly confused how may I do it.

If any one of esteemed members of the group may suggest.

Regards,
Subhabrata Banerjee. 




-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating .exe file in Python

2015-06-17 Thread subhabrata . banerji
On Wednesday, June 17, 2015 at 6:50:48 PM UTC+5:30, Chris Angelico wrote:
 On Wed, Jun 17, 2015 at 11:10 PM, wrote:
  Thank you all. It seems going fine now. I have one additional question if I 
  run the .exe files created in Non Python Windows environment. Linux has 
  Python builtin but in Non Python environment how may I run it? Is there any 
  set of prequisites I have to follow. I am not finding much web help, if any 
  one may kindly suggest.
 
 
 There have been some proposals to make an easy way to produce a single
 package that has a Windows executable header, but can be easily
 unpacked and run using a system-provided Linux or Mac OS Python.
 However, I don't think any have been deployed yet. So the simple
 answer is: You can't do what you're trying to do. Instead, take a step
 back, and look at just getting your Python program to run on all
 platforms... and that's easy, just distribute the .py files. Much MUCH
 easier, more reliable, and simpler.
 
 ChrisA

Dear Sir,

Thank you for your kind and prompt answer. I was about to explore another 
package. Regards, Subhabrata Banerjee.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating .exe file in Python

2015-06-17 Thread subhabrata . banerji
On Tuesday, June 16, 2015 at 9:33:58 PM UTC+5:30, Chris Angelico wrote:
 On Wed, Jun 17, 2015 at 1:17 AM, wrote:
  Thanks. The scipy issue seems solved. But this silly issue is giving so 
  much of time. I am checking. Please see a sample code,
 
  import sys
  sys.stderr = sys.stdout
  class Colors:
  def Blue(self):
  self.var=This is Blue
  print self.var
  def Red(self):
  print self.var
 
 
 
  if __name__ == __main__:
  Colors().Blue() #THIS IS FINE
  Colors().Red() #NOT FINE
 
 You're still not saying what's going on. Did you try this code as a
 simple Python script first, before trying to bundle it up into an .exe
 file?
 
 Fortunately, my primary crystal ball is active, and I believe what's
 going on is that you expect Blue() to set something and then Red() to
 see it. However, you're calling those methods on two different
 throw-away objects, so they have separate state. What you expect to
 happen, I honestly have no idea. (Also, why are you fiddling with
 sys.stderr? You don't then appear to be using it, unless you have an
 issue with exceptions getting printed to the other stream.)
 
 ChrisA

Dear Group,

Thank you all. It seems going fine now. I have one additional question if I run 
the .exe files created in Non Python Windows environment. Linux has Python 
builtin but in Non Python environment how may I run it? Is there any set of 
prequisites I have to follow. I am not finding much web help, if any one may 
kindly suggest. 

Regards,
Subhabrata Banerjee.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating .exe file in Python

2015-06-17 Thread subhabrata . banerji
On Wednesday, June 17, 2015 at 7:25:39 PM UTC+5:30, Laura Creighton wrote:
 In a message of Wed, 17 Jun 2015 06:10:45 -0700, w
 rites:
 
 Dear Group,
 
 Thank you all. It seems going fine now. I have one additional question if I 
 run the .exe files created in Non Python Windows environment. Linux has 
 Python builtin but in Non Python environment how may I run it? Is there any 
 set of prequisites I have to follow. I am not finding much web help, if any 
 one may kindly suggest. 
 
 Regards,
 Subhabrata Banerjee.
 
 If you use py2exe or PyInstaller (or whatever it is you used) to make
 your exe, then all of this is handled for you.  Hand the windows users
 the exe and they are good to go.  But the last time you posted here,
 your py2exe wasn't working well.  You were getting Import Errors.
 If you make a broken exe, well, it will be broken for the windows
 users as well.
 
 Laura

Thanks. I will check. I am calling the .exe from C:\Python27\dist... would it 
run in non Python Windows Environment? Regards, Subhabrata Banerjee.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating .exe file in Python

2015-06-17 Thread subhabrata . banerji
On Monday, June 15, 2015 at 5:12:24 PM UTC+5:30, subhabrat...@gmail.com wrote:
 Dear Group,
 
 I am trying to learn how to create .exe file for Python. I tried to work 
 around 
 http://www.py2exe.org/index.cgi/Tutorial of Py2exe. The sample program went 
 nice.
 But if I try to make exe for larger programs with methods and classes I am 
 getting error. 
 
 If any one of the esteemed members may kindly suggest how to work out. 
 I am using Python2.7+ on Windows 7 Professional. 
 
 Regards,
 Subhabrata Banerjee.

But if I am moving the file from Python environment and to another folder in C: 
drive it is not running, it is giving me following error messages,
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\tutorialhello.exe
LoadLibrary(pythondll) failedThe specified module could not be found.
C:\tutorial\PYTHON27.DLL
C:\tutorial

Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating .exe file in Python

2015-06-17 Thread subhabrata . banerji
On Wednesday, June 17, 2015 at 7:47:59 PM UTC+5:30, rand...@fastmail.us wrote:
 On Wed, Jun 17, 2015, at 09:33, hamilton wrote:
  However, the python source can be read by anyone.
  
  As a .exe, the source can not be read.
  
  Just because the interpreter is open source,
  does not mean my application should be.
 
 Being readable isn't the same thing as being open source. If someone
 steals your application, you can sue them.

Guido can create another Python. I know my limits. So I never steal or copy 
unnecessarily I learn. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating .exe file in Python

2015-06-17 Thread subhabrata . banerji
On Wednesday, June 17, 2015 at 8:52:16 PM UTC+5:30, Laura Creighton wrote:
 In a message of Wed, 17 Jun 2015 07:16:33 -0700,  w
 rites:
 On Monday, June 15, 2015 at 5:12:24 PM UTC+5:30, wrote:
  Dear Group,
  
  I am trying to learn how to create .exe file for Python. I tried to work 
  around 
  http://www.py2exe.org/index.cgi/Tutorial of Py2exe. The sample program 
  went nice.
  But if I try to make exe for larger programs with methods and classes I am 
  getting error. 
  
  If any one of the esteemed members may kindly suggest how to work out. 
  I am using Python2.7+ on Windows 7 Professional. 
  
  Regards,
  Subhabrata Banerjee.
 
 But if I am moving the file from Python environment and to another folder in 
 C: drive it is not running, it is giving me following error messages,
 Microsoft Windows [Version 6.1.7601]
 Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
 
 C:\tutorialhello.exe
 LoadLibrary(pythondll) failedThe specified module could not be found.
 C:\tutorial\PYTHON27.DLL
 C:\tutorial
 
 Regards,
 Subhabrata Banerjee. 
 
 You have to distribute the DLL as well.
 But at this point you need somebody who knows more about packaging
 for windows than I do.  It's not something I do often, or well.
 
 Laura

Hi,
My need is done. But I can learn. I saw few .pyd files in dist folder.
Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating .exe file in Python

2015-06-17 Thread subhabrata . banerji
On Wednesday, June 17, 2015 at 9:09:32 PM UTC+5:30, Steven D'Aprano wrote:
 On Wed, 17 Jun 2015 11:52 pm, Chris Angelico wrote:
 
  If you truly want to protect your code from prying eyes, therefore,
  there's only one way to do it: host it on a server, and let people
  access the server without seeing the code.
 
 Stop giving people ideas.
 
 
 
 -- 
 Steven

Why sir?
Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating .exe file in Python

2015-06-16 Thread subhabrata . banerji
On Monday, June 15, 2015 at 9:59:33 PM UTC+5:30, Laura Creighton wrote:
 I don't have a windows system, so my knowledge of such things is
 minimal.  But looks like this person had the same problem you have,
 and got some suggestions on how to fix it.
 
 http://stackoverflow.com/questions/12127869/error-msvcp90-dll-no-such-file-or-directory-even-though-microsoft-visual-c
 
 But your code is working fine now?  There is no point in packaging
 something that doesn't run.
 
 Laura

I have mostly solved the problem. But there are two issues making me slightly 
confusing:
i) In a bigger code I am calling scipy and after building .exe as I am calling 
\dist\...exe it is giving ImportError: No module named _ufuncs_cxx
I have checked the resolution 
http://stackoverflow.com/questions/20169728/exe-created-with-py2exe-doesnt-work-and-returns-logfile-with-errors
but it is not giving much help.
ii) In a class how may I include if __name__ == __main__: with multiple 
methods? But I think this is easy question there should be lot of web help. 

If anyone may kindly suggest.

Regards,
Subhabrata Banerjee. 
 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating .exe file in Python

2015-06-16 Thread subhabrata . banerji
On Tuesday, June 16, 2015 at 8:35:39 PM UTC+5:30, Laura Creighton wrote:
 In a message of Tue, 16 Jun 2015 06:56:12 -0700,  writes:
 ii) In a class how may I include if __name__ == __main__: with multiple 
 methods? But I think this is easy question there should be lot of web help. 
 
 If anyone may kindly suggest.
 
 Regards,
 Subhabrata Banerjee. 
 
 There is something wrong in the way you are thinking about this.
 You don't _want_ to stick if __name__ = __main__:
 into every class you write.
 
 See if reading this helps.
 http://effbot.org/pyfaq/tutor-what-is-if-name-main-for.htm
 
 Laura

Hi,
Thanks. The scipy issue seems solved. But this silly issue is giving so much of 
time. I am checking. Please see a sample code, 

import sys
sys.stderr = sys.stdout
class Colors:
def Blue(self):
self.var=This is Blue
print self.var
def Red(self):
print self.var


   
if __name__ == __main__:
Colors().Blue() #THIS IS FINE
Colors().Red() #NOT FINE

Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating .exe file in Python

2015-06-16 Thread subhabrata . banerji
On Tuesday, June 16, 2015 at 9:33:58 PM UTC+5:30, Chris Angelico wrote:
 On Wed, Jun 17, 2015 at 1:17 AM,  wrote:
  Thanks. The scipy issue seems solved. But this silly issue is giving so 
  much of time. I am checking. Please see a sample code,
 
  import sys
  sys.stderr = sys.stdout
  class Colors:
  def Blue(self):
  self.var=This is Blue
  print self.var
  def Red(self):
  print self.var
 
 
 
  if __name__ == __main__:
  Colors().Blue() #THIS IS FINE
  Colors().Red() #NOT FINE
 
 You're still not saying what's going on. Did you try this code as a
 simple Python script first, before trying to bundle it up into an .exe
 file?
 
 Fortunately, my primary crystal ball is active, and I believe what's
 going on is that you expect Blue() to set something and then Red() to
 see it. However, you're calling those methods on two different
 throw-away objects, so they have separate state. What you expect to
 happen, I honestly have no idea. (Also, why are you fiddling with
 sys.stderr? You don't then appear to be using it, unless you have an
 issue with exceptions getting printed to the other stream.)
 
 ChrisA

Thank you for your reply. I am trying to experimenting over small ones before 
going to actual code. Your error interpretations are right.
I could work out a small solution please check if it is going fine.
It is giving me result.

if __name__ == __main__:
c1=Colors()
c2=c1.Blue()
c3=c1.Red()

Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating .exe file in Python

2015-06-16 Thread subhabrata . banerji
On Monday, June 15, 2015 at 9:59:33 PM UTC+5:30, Laura Creighton wrote:
 I don't have a windows system, so my knowledge of such things is
 minimal.  But looks like this person had the same problem you have,
 and got some suggestions on how to fix it.
 
 http://stackoverflow.com/questions/12127869/error-msvcp90-dll-no-such-file-or-directory-even-though-microsoft-visual-c
 
 But your code is working fine now?  There is no point in packaging
 something that doesn't run.
 
 Laura

Hi,

Thank you for your help. Yes now the file is giving output as I am calling it 
in command prompt. I had downloaded Microsoft Visual Studio 2008 
Redistributable.
I have MS VC 10.0 installed so my corresponding CRT file is 100 and not 90. I 
am checking this and working out. 
Meanwhile got another post 
http://stackoverflow.com/questions/323424/py2exe-fails-to-generate-an-executable
and pasted libiomp5md.dll from numpy now it is giving NLQ3.exe in dist and 
generating few errors in a corresponding log file.

Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Creating .exe file in Python

2015-06-15 Thread subhabrata . banerji
Dear Group,

I am trying to learn how to create .exe file for Python. I tried to work around 
http://www.py2exe.org/index.cgi/Tutorial of Py2exe. The sample program went 
nice.
But if I try to make exe for larger programs with methods and classes I am 
getting error. 

If any one of the esteemed members may kindly suggest how to work out. 
I am using Python2.7+ on Windows 7 Professional. 

Regards,
Subhabrata Banerjee. 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating .exe file in Python

2015-06-15 Thread subhabrata . banerji
On Monday, June 15, 2015 at 5:12:24 PM UTC+5:30, subhabrat...@gmail.com wrote:
 Dear Group,
 
 I am trying to learn how to create .exe file for Python. I tried to work 
 around 
 http://www.py2exe.org/index.cgi/Tutorial of Py2exe. The sample program went 
 nice.
 But if I try to make exe for larger programs with methods and classes I am 
 getting error. 
 
 If any one of the esteemed members may kindly suggest how to work out. 
 I am using Python2.7+ on Windows 7 Professional. 
 
 Regards,
 Subhabrata Banerjee.

I am also experimenting around Pyinstaller, cx_Freeze and Inno Studio. But not 
finding ample examples and manuals. 
Regards,
Subhabrata. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating .exe file in Python

2015-06-15 Thread subhabrata . banerji
On Monday, June 15, 2015 at 6:32:33 PM UTC+5:30, Laura Creighton wrote:
 In a message of Mon, 15 Jun 2015 04:42:09 -0700,  w
 rites:
 Dear Group,
 
 I am trying to learn how to create .exe file for Python. I tried to work 
 around 
 http://www.py2exe.org/index.cgi/Tutorial of Py2exe. The sample program went 
 nice.
 But if I try to make exe for larger programs with methods and classes I am 
 getting error. 
 
 If any one of the esteemed members may kindly suggest how to work out. 
 I am using Python2.7+ on Windows 7 Professional. 
 
 Regards,
 Subhabrata Banerjee. 
 
 1. Post the error.
 
 2. I have always had better luck with PyInstaller than with py2exe
https://github.com/pyinstaller/pyinstaller/wiki
 
 Laura
Dear Group,

I wrote a script as NLQ3. py 

the code is written as, 

import nltk
import itertools 
def nlq3(n):
inp=raw_input(Print Your Query:)
tag=nltk.pos_tag(nltk.wordpunct_tokenize(inp))
print The Tagged Value Is:,tag
noun=[word[0] for word in tag if 'NN' in word[1]]
#print noun
#COMBINATION OF ALL ELEMENTS
for i in xrange(1,len(noun)+1):
comb= list(itertools.combinations(noun,i))
for i,v in enumerate(comb):
#print v
v1=list(v)
print v1

I tried to call it as,
C:\Tutorialpython hello.py
...
as 

C:\Python27python NLQ3.py

C:\Python27

But I am not getting any output.

Next I tried to create setup.py as,

from distutils.core import setup
import py2exe
setup(console=['NLQ3.py'])

and trying to work out as,


C:\Python27python setup.py install
running install
running build
running install_egg_info
Removing C:\Python27\Lib\site-packages\UNKNOWN-0.0.0-py2.7.egg-info
Writing C:\Python27\Lib\site-packages\UNKNOWN-0.0.0-py2.7.egg-info

C:\Python27

Now, 
as I am giving 
C:\Python27python setup.py py2exe

it is giving me the following result,
running py2exe
*** searching for required modules ***
*** parsing results ***
creating python loader for extension 'scipy.optimize.minpack2' (C:\Python27\lib\
site-packages\scipy\optimize\minpack2.pyd - scipy.optimize.minpack2.pyd)
creating python loader for extension 'numpy.core.umath' (C:\Python27\lib\site-pa
ckages\numpy\core\umath.pyd - numpy.core.umath.pyd)
creating python loader for extension '_elementtree' (C:\Python27\DLLs\_elementtr
ee.pyd - _elementtree.pyd)
creating python loader for extension 'matplotlib._path' (C:\Python27\lib\site-pa
ckages\matplotlib\_path.pyd - matplotlib._path.pyd)
creating python loader for extension 'numpy.fft.fftpack_lite' (C:\Python27\lib\s
ite-packages\numpy\fft\fftpack_lite.pyd - numpy.fft.fftpack_lite.pyd)
creating python loader for extension 'numpy.lib._compiled_base' (C:\Python27\lib
\site-packages\numpy\lib\_compiled_base.pyd - numpy.lib._compiled_base.pyd)
creating python loader for extension 'scipy.optimize._minpack' (C:\Python27\lib\
site-packages\scipy\optimize\_minpack.pyd - scipy.optimize._minpack.pyd)
creating python loader for extension '_ctypes' (C:\Python27\DLLs\_ctypes.pyd -
_ctypes.pyd)
creating python loader for extension 'scipy.sparse.linalg.isolve._iterative' (C:
\Python27\lib\site-packages\scipy\sparse\linalg\isolve\_iterative.pyd - scipy.s
parse.linalg.isolve._iterative.pyd)
creating python loader for extension 'sklearn.linear_model.sgd_fast' (C:\Python2
7\lib\site-packages\sklearn\linear_model\sgd_fast.pyd - sklearn.linear_model.sg
d_fast.pyd)
creating python loader for extension 'scipy.stats._rank' (C:\Python27\lib\site-p
ackages\scipy\stats\_rank.pyd - scipy.stats._rank.pyd)
creating python loader for extension 'select' (C:\Python27\DLLs\select.pyd - se
lect.pyd)
creating python loader for extension 'scipy.sparse.csgraph._reordering' (C:\Pyth
on27\lib\site-packages\scipy\sparse\csgraph\_reordering.pyd - scipy.sparse.csgr
aph._reordering.pyd)
creating python loader for extension 'unicodedata' (C:\Python27\DLLs\unicodedata
.pyd - unicodedata.pyd)
creating python loader for extension 'scipy.special.specfun' (C:\Python27\lib\si
te-packages\scipy\special\specfun.pyd - scipy.special.specfun.pyd)
creating python loader for extension 'scipy.spatial.qhull' (C:\Python27\lib\site
-packages\scipy\spatial\qhull.pyd - scipy.spatial.qhull.pyd)
creating python loader for extension 'scipy.interpolate._ppoly' (C:\Python27\lib
\site-packages\scipy\interpolate\_ppoly.pyd - scipy.interpolate._ppoly.pyd)
creating python loader for extension 'scipy.sparse.csgraph._tools' (C:\Python27\
lib\site-packages\scipy\sparse\csgraph\_tools.pyd - scipy.sparse.csgraph._tools
.pyd)
creating python loader for extension 'scipy.interpolate.dfitpack' (C:\Python27\l
ib\site-packages\scipy\interpolate\dfitpack.pyd - scipy.interpolate.dfitpack.py
d)
creating python loader for extension 'scipy.linalg._fblas' (C:\Python27\lib\site
-packages\scipy\linalg\_fblas.pyd - scipy.linalg._fblas.pyd)
creating python loader for extension 'scipy.optimize._zeros' (C:\Python27\lib\si
te-packages\scipy\optimize\_zeros.pyd - scipy.optimize._zeros.pyd)
creating python loader for 

Re: Creating .exe file in Python

2015-06-15 Thread subhabrata . banerji
On Monday, June 15, 2015 at 8:02:21 PM UTC+5:30, Thierry Chappuis wrote:
 Hi,
 
 The question is why to you want to create an exe from your 
 python project?
 
 Setuptools is capable to create small .exe launchers in the 
 Scripts dir of your python install. These launchers start a python script 
 and use the python interpreter registered on your platform. That's pretty 
 light and that's my prefered solution.
 
 If installing the Python interpreter is an issue for the end 
 user, we can make the installer do it for him. Installer programs like Inno 
 Setup let you do it quite easily.
 
 Kind regards
 
 Thierry
 
 
 
 On lun., juin 15, 2015 at 
 4:10 PM,  subhabrat...@gmail.com 
 wrote:
 
 
 On Monday, June 15, 2015 at 
 5:12:24 PM UTC+5:30, subhabrat...@gmail.com wrote:
 
 
  Dear Group,
 
 
  
 
 
  I am trying to learn how to create .exe file for Python. I tried to 
 work around 
 
 
  http://www.py2exe.org/index.cgi/Tutorial of Py2exe. The sample program 
 went nice.
 
 
  But if I try to make exe for larger programs with methods and classes 
 I am getting error. 
 
 
  
 
 
  If any one of the esteemed members may kindly suggest how to work out. 
 
 
 
  I am using Python2.7+ on Windows 7 Professional. 
 
 
  
 
 
  Regards,
 
 
  Subhabrata Banerjee.
 
 
 
 
 
 I am also experimenting around Pyinstaller, cx_Freeze and Inno Studio. But 
 not finding ample examples and manuals. 
 
 
 Regards,
 
 
 Subhabrata. 
 
 
 -- 
 
 
 https://mail.python.org/mailman/listinfo/python-list

Thank you for your kind reply. I have downloaded it, but no good tutorial. If 
you may send any. Regards, Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating .exe file in Python

2015-06-15 Thread subhabrata . banerji
On Monday, June 15, 2015 at 5:12:24 PM UTC+5:30, subhabrat...@gmail.com wrote:
 Dear Group,
 
 I am trying to learn how to create .exe file for Python. I tried to work 
 around 
 http://www.py2exe.org/index.cgi/Tutorial of Py2exe. The sample program went 
 nice.
 But if I try to make exe for larger programs with methods and classes I am 
 getting error. 
 
 If any one of the esteemed members may kindly suggest how to work out. 
 I am using Python2.7+ on Windows 7 Professional. 
 
 Regards,
 Subhabrata Banerjee.

Dear Madam,

Thanks. Most of it is working except the last portion as I am giving 
python setup.py py2exe

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Admincd\

C:\cd Python27

C:\Python27python NLQ3.py
Print Your Query:Java
The Tagged Value Is: [('Java', 'NNP')]
['Java']

C:\Python27python NLQ3.py
Print Your Query:Obama is the president of USA
The Tagged Value Is: [('Obama', 'NNP'), ('is', 'VBZ'), ('the', 'DT'), ('presiden
t', 'NN'), ('of', 'IN'), ('USA', 'NNP')]
['Obama']
['president']
['USA']
['Obama', 'president']
['Obama', 'USA']
['president', 'USA']
['Obama', 'president', 'USA']

C:\Python27python setup.py install
running install
running build
running install_egg_info
Removing C:\Python27\Lib\site-packages\UNKNOWN-0.0.0-py2.7.egg-info
Writing C:\Python27\Lib\site-packages\UNKNOWN-0.0.0-py2.7.egg-info

C:\Python27python setup.py py2exe
running py2exe
*** searching for required modules ***
*** parsing results ***
creating python loader for extension 'scipy.optimize.minpack2' (C:\Python27\lib\
site-packages\scipy\optimize\minpack2.pyd - scipy.optimize.minpack2.pyd)
creating python loader for extension 'numpy.core.umath' (C:\Python27\lib\site-pa
ckages\numpy\core\umath.pyd - numpy.core.umath.pyd)
creating python loader for extension '_elementtree' (C:\Python27\DLLs\_elementtr
ee.pyd - _elementtree.pyd)
creating python loader for extension 'matplotlib._path' (C:\Python27\lib\site-pa
ckages\matplotlib\_path.pyd - matplotlib._path.pyd)
creating python loader for extension 'numpy.fft.fftpack_lite' (C:\Python27\lib\s
ite-packages\numpy\fft\fftpack_lite.pyd - numpy.fft.fftpack_lite.pyd)
creating python loader for extension 'numpy.lib._compiled_base' (C:\Python27\lib
\site-packages\numpy\lib\_compiled_base.pyd - numpy.lib._compiled_base.pyd)
creating python loader for extension 'scipy.optimize._minpack' (C:\Python27\lib\
site-packages\scipy\optimize\_minpack.pyd - scipy.optimize._minpack.pyd)
creating python loader for extension '_ctypes' (C:\Python27\DLLs\_ctypes.pyd -
_ctypes.pyd)
creating python loader for extension 'scipy.sparse.linalg.isolve._iterative' (C:
\Python27\lib\site-packages\scipy\sparse\linalg\isolve\_iterative.pyd - scipy.s
parse.linalg.isolve._iterative.pyd)
creating python loader for extension 'sklearn.linear_model.sgd_fast' (C:\Python2
7\lib\site-packages\sklearn\linear_model\sgd_fast.pyd - sklearn.linear_model.sg
d_fast.pyd)
creating python loader for extension 'scipy.stats._rank' (C:\Python27\lib\site-p
ackages\scipy\stats\_rank.pyd - scipy.stats._rank.pyd)
creating python loader for extension 'select' (C:\Python27\DLLs\select.pyd - se
lect.pyd)
creating python loader for extension 'scipy.sparse.csgraph._reordering' (C:\Pyth
on27\lib\site-packages\scipy\sparse\csgraph\_reordering.pyd - scipy.sparse.csgr
aph._reordering.pyd)
creating python loader for extension 'unicodedata' (C:\Python27\DLLs\unicodedata
.pyd - unicodedata.pyd)
creating python loader for extension 'scipy.special.specfun' (C:\Python27\lib\si
te-packages\scipy\special\specfun.pyd - scipy.special.specfun.pyd)
creating python loader for extension 'scipy.spatial.qhull' (C:\Python27\lib\site
-packages\scipy\spatial\qhull.pyd - scipy.spatial.qhull.pyd)
creating python loader for extension 'scipy.interpolate._ppoly' (C:\Python27\lib
\site-packages\scipy\interpolate\_ppoly.pyd - scipy.interpolate._ppoly.pyd)
creating python loader for extension 'scipy.sparse.csgraph._tools' (C:\Python27\
lib\site-packages\scipy\sparse\csgraph\_tools.pyd - scipy.sparse.csgraph._tools
.pyd)
creating python loader for extension 'scipy.interpolate.dfitpack' (C:\Python27\l
ib\site-packages\scipy\interpolate\dfitpack.pyd - scipy.interpolate.dfitpack.py
d)
creating python loader for extension 'scipy.linalg._fblas' (C:\Python27\lib\site
-packages\scipy\linalg\_fblas.pyd - scipy.linalg._fblas.pyd)
creating python loader for extension 'scipy.optimize._zeros' (C:\Python27\lib\si
te-packages\scipy\optimize\_zeros.pyd - scipy.optimize._zeros.pyd)
creating python loader for extension 'scipy.stats.mvn' (C:\Python27\lib\site-pac
kages\scipy\stats\mvn.pyd - scipy.stats.mvn.pyd)
creating python loader for extension 'sklearn.__check_build._check_build' (C:\Py
thon27\lib\site-packages\sklearn\__check_build\_check_build.pyd - sklearn.__che
ck_build._check_build.pyd)
creating python loader for extension 'scipy.linalg._flinalg' (C:\Python27\lib\si
te-packages\scipy\linalg\_flinalg.pyd - 

Re: How may I Integrate Python Code with REST

2015-06-13 Thread subhabrata . banerji
On Saturday, June 13, 2015 at 2:17:43 AM UTC+5:30, Laura Creighton wrote:
 In a message of Fri, 12 Jun 2015 10:52:19 -0700,  w
 rites:
 Dear Group,
 
 I wrote a Python code. In the code there are two modules where we may insert 
 data from outside. They are updating some training module and updating 
 index. As a standalone code this is working fine. 
 
 I need to port this code to REST. I tried to learn Flask. My Practice for 
 Flask is okay. I can put,get,delete. 
 
 But how may I proceed I am not getting much idea. I bit new in REST. 
 If any one of the esteemed members may kindly provide an idea how may I 
 proceed? 
 
 Regards,
 Subhabrata Banerjee.  
 
 All you need now is post.  So it looks as if you have  all the bits you
 need, but you don't know how to use them to design an API.
 
 See if this helps.
 http://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
 
 If not, you are probably at the stage of posting code here.
 Here is my code that doesn't work.
 Here is what happens when I run it.
 This is what I wish it would do instead.
 
 Right now we don't understand what it is that you don't understand, alas.
 Code makes the problem obvious.
 
 Laura

Hi,

Thank you for your post. Yes I can PUT the data in JSON format but how to 
interact with the code I am thinking on that. My script snippet of Flask is as
follows,
 x3=requests.put('http://127.0.0.1:5000/todos/todo1', data={'task': 'We are 
 trying to build API. API seems okay.'})
 x4=requests.get('http://127.0.0.1:5000/todos')
 x5=x4.text
 print x5
{
todo1: {
task: We are trying to build API. API seems okay.
}, 
todo2: {
task: Change my brakepads
}, 
todo3: {
task: Life is okay
}
}

Now, as I understand it I have to work out something around this PUT. 
As per my guess, 
1. I should work around this put if takes data from file.
2. The data I would get thus, I have to convert this JSON data (by import json 
or so), into text or the format my main code understands as input.

Am I thinking fine. If not please suggest. 

There is an interesting error occurs almost every other day port 5000
in 
requests.get('http://127.0.0.1:5000/todos') gives error everyother day.
I have stopped firewall, consulted senior administrators of system group but no 
error seems there. It works suddenly and does not work suddenly,
if you suggest how to fix this issue. 

I am using Python2.7+ on MS-Windows 7 Professional. I am using Microsoft 
Security Essentials as AntiVirus. 

Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


How may I Integrate Python Code with REST

2015-06-12 Thread subhabrata . banerji
Dear Group,

I wrote a Python code. In the code there are two modules where we may insert 
data from outside. They are updating some training module and updating index. 
As a standalone code this is working fine. 

I need to port this code to REST. I tried to learn Flask. My Practice for Flask 
is okay. I can put,get,delete. 

But how may I proceed I am not getting much idea. I bit new in REST. 
If any one of the esteemed members may kindly provide an idea how may I 
proceed? 

Regards,
Subhabrata Banerjee.  
-- 
https://mail.python.org/mailman/listinfo/python-list


Error in or

2015-06-11 Thread subhabrata . banerji
Dear Group,

In the following script,

  inp1=raw_input(PRINT YOUR INPUT:)
  if (AND in inp1) or (OR in inp1) or (NOT in inp1) or ( in inp1) or 
( in inp1) or (MAYBE in inp1) or (( in inp1) or (* in inp1):
  
  if write this it is working fine, but if I write 
   
  if (AND in inp1) or (OR in inp1) or (NOT in inp1) or ( in inp1) or 
( in inp1) or (MAYBE in inp1) or (( in inp1) or (* in inp1) or ('''  
''' in   inp1):
  
 the portion of ('''  ''' in   inp1) is not working.

If any one of the esteemed members may kindly suggest the error I am making.

I am using Python2.7+ on Windows 7 Professional. 

Apology for any indentation error. 

Regards,
Subhabrata Banerjee. 
 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Error in or

2015-06-11 Thread subhabrata . banerji
On Thursday, June 11, 2015 at 9:20:59 PM UTC+5:30, Ian wrote:
 On Thu, Jun 11, 2015 at 9:40 AM,  
if write this it is working fine, but if I write
 
if (AND in inp1) or (OR in inp1) or (NOT in inp1) or ( in inp1) 
  or ( in inp1) or (MAYBE in inp1) or (( in inp1) or (* in inp1) or 
  ('''  ''' in   inp1):
 
   the portion of ('''  ''' in   inp1) is not working.
 
 Not working how? I copy-pasted the line and it appears to work fine.

Dear Sir,
Thank you for your kind reply. Nice to know your reply, but I am trying to send 
you my experiment, please see my results,

 def input1(n):
inp1=raw_input(PRINT YOUR QUERY:)
if (AND in inp1) or (OR in inp1) or (NOT in inp1) or ( in 
inp1) or ( in inp1) or (MAYBE in inp1) or (( in inp1) or (* in inp1) 
or ('''  ''' in   inp1):
print FINE


 input1(1)
PRINT YOUR QUERY:Java
 input1(1)
PRINT YOUR QUERY:Obama in London
 input1(1)
PRINT YOUR QUERY:Obama AND Bush
FINE
 input1(1)
PRINT YOUR QUERY:Obama OR Bush
FINE
 

you may get better my problem. 

Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Error in or

2015-06-11 Thread subhabrata . banerji
On Thursday, June 11, 2015 at 10:18:33 PM UTC+5:30, Ian wrote:
 On Thu, Jun 11, 2015 at 10:39 AM,   wrote:
  On Thursday, June 11, 2015 at 9:20:59 PM UTC+5:30, Ian wrote:
  On Thu, Jun 11, 2015 at 9:40 AM,
 if write this it is working fine, but if I write
  
 if (AND in inp1) or (OR in inp1) or (NOT in inp1) or ( in 
   inp1) or ( in inp1) or (MAYBE in inp1) or (( in inp1) or (* in 
   inp1) or ('''  ''' in   inp1):
  
the portion of ('''  ''' in   inp1) is not working.
 
  Not working how? I copy-pasted the line and it appears to work fine.
 
  Dear Sir,
  Thank you for your kind reply. Nice to know your reply, but I am trying to 
  send you my experiment, please see my results,
 
  def input1(n):
  inp1=raw_input(PRINT YOUR QUERY:)
  if (AND in inp1) or (OR in inp1) or (NOT in inp1) or ( in 
  inp1) or ( in inp1) or (MAYBE in inp1) or (( in inp1) or (* in 
  inp1) or ('''  ''' in   inp1):
  print FINE
 
 
  input1(1)
  PRINT YOUR QUERY:Java
  input1(1)
  PRINT YOUR QUERY:Obama in London
  input1(1)
  PRINT YOUR QUERY:Obama AND Bush
  FINE
  input1(1)
  PRINT YOUR QUERY:Obama OR Bush
  FINE
 
 
  you may get better my problem.
 
 The substring that you're looking for has spaces around the  symbol.
 The example inputs that you gave don't have spaces around the 
 symbols, so they don't contain the substring.  The triple quotes are
 also unnecessary, though harmless -- it's not a multiline string, and
 there are no ' symbols to escape in the string. Try replacing the
 substring with just this: ''.

Dear Sir,
Thank you. It seems working.
Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Model Dumping Pickle

2015-05-30 Thread subhabrata . banerji
Dear Group,

If I use pickle to dump my model as follows, 

 from gensim.models import Word2Vec
 from nltk.corpus import brown, movie_reviews, treebank
 b = Word2Vec(brown.sents())
 import pickle
 f = open('my_classifier5.pickle', 'wb')
 pickle.dump(b, f)
 f.close()
 f1= open('my_classifier5.pickle')
 classifier=pickle.load(f1)
 classifier.most_similar('money', topn=5)
[('pay', 0.6861867904663086), ('ready', 0.6255729794502258), ('try', 
0.6118115186691284), ('go', 0.609034538269043), ('oppose', 0.6002943515777588)]
 f1.close()

Am I going fine? If any one may kindly suggest. 

I am using Python 2.7 on MS-Windows 7 Professional. 
Apology for any indentation error.

Regards,
Subhabrata Banerjee. 

-- 
https://mail.python.org/mailman/listinfo/python-list


Inverted Comma Search

2015-05-29 Thread subhabrata . banerji
Dear Group,

I am trying to implement two searches, inverted comma search and search within 
brackets. I am trying to implement them in Whoosh, but not finding good 
tutorial or examples. If any one may kindly help me with.

Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


REST framework Editor in Python

2015-05-20 Thread subhabrata . banerji
Dear Group,

I am trying to put one search engine interface in REST. 
To do this I am trying to learn Restframework and Django. 
One question occurred to me is, whether there is any Restframework editor
which may do this job.

Is there any? 

I was trying to find out https://pypi.python.org/pypi/restview -is it doing 
this?
In that case, if any one may kindly share some examples or tutorial for it.

Thanks in advance,
Regards,
Subhabrata Banerjee.  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask Post returning error

2015-05-19 Thread subhabrata . banerji
On Tuesday, May 19, 2015 at 10:34:35 AM UTC+5:30, Miki Tebeka wrote:
  If anyone may kindly suggest what is the error I am doing. 
 It's close to impossible to know without seeing the server side code.

Dear Sir,

I am trying to paste the code from:
from flask import Flask
from flask_restful import reqparse, abort, Api, Resource

app = Flask(__name__)
api = Api(app)

TODOS = {
'todo1': {'task': 'build an API'},
'todo2': {'task': 'How are you?'},
'todo3': {'task': 'profit!'},
}


def abort_if_todo_doesnt_exist(todo_id):
if todo_id not in TODOS:
abort(404, message=Todo {} doesn't exist.format(todo_id))

parser = reqparse.RequestParser()
parser.add_argument('task', type=str)


# Todo
# shows a single todo item and lets you delete a todo item
class Todo(Resource):
def get(self, todo_id):
abort_if_todo_doesnt_exist(todo_id)
return TODOS[todo_id]

def delete(self, todo_id):
abort_if_todo_doesnt_exist(todo_id)
del TODOS[todo_id]
return '', 204

def put(self, todo_id):
args = parser.parse_args()
task = {'task': args['task']}
TODOS[todo_id] = task
return task, 201


# TodoList
# shows a list of all todos, and lets you POST to add new tasks
class TodoList(Resource):
def get(self):
return TODOS

def post(self):
args = parser.parse_args()
todo_id = int(max(TODOS.keys()).lstrip('todo')) + 1
todo_id = 'todo%i' % todo_id
TODOS[todo_id] = {'task': args['task']}
return TODOS[todo_id], 201

##
## Actually setup the Api resource routing here
##
api.add_resource(TodoList, '/todos')
api.add_resource(Todo, '/todos/todo_id')


if __name__ == '__main__':
app.run(debug=True)

taken from:
http://flask.pocoo.org/docs/0.10/quickstart/

Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Flask Post returning error

2015-05-18 Thread subhabrata . banerji
Dear Group,

I am trying to practice Flask and trying to correspond with it with through 
requests. 

I am being able to DELETE, GET. But as I am doing POST it is not posting the 
data rather returning null. 

I tried to search Flask and requests tutorials but did not get much. 
I am newly practising Flask, and on Python2.7+ with Windows 7 Professional. 

 var1=requests.get('http://127.0.0.1:5000/todos')
 var2=var2.text
 print var3
{
todo1: {
task: build an API
}, 
todo2: {
task: How are you?
}, 
todo3: {
task: profit!
}
}
 import json
 payload = {'key1': 'value1'}
 var4=requests.post('http://127.0.0.1:5000/todos', data=json.dumps(payload))
 var5=requests.get('http://127.0.0.1:5000/todos')
 var6=var5.text
 print var6
{
todo1: {
task: build an API
}, 
todo3: {
task: null
}
}

If anyone may kindly suggest what is the error I am doing. 

Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Integrating Python Code with Django

2015-05-13 Thread subhabrata . banerji
Dear Group,

I am trying to learn Django. My initial exercise seems fine. I want to create 
an API with REST on Django for an interactive Python code. REST framework on 
Django I am understanding more or less. 

I am looking for a simple example to start with. I am using Python 2.7+ on 
MS-Windows 7 Professional. 

If any one may kindly suggest. 

Regards,
Subhabrata Banerjee. 

-- 
https://mail.python.org/mailman/listinfo/python-list


IDLE Restoration

2015-05-08 Thread subhabrata . banerji
Dear Group,

In many applications there is a facility to restore its previous sessions, 
especially if they close accidentally. 

Does IDLE have any such facility? 
If it is there, how may I use it?

If someone may kindly suggest it.

Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fast way of extracting files from various folders

2015-05-02 Thread subhabrata . banerji
On Saturday, May 2, 2015 at 2:52:32 PM UTC+5:30, Peter Otten wrote:
  wrote:
 
  I have several millions of documents in several folders and subfolders in
  my machine. I tried to write a script as follows, to extract all the .doc
  files and to convert them in text, but it seems it is taking too much of
  time.
  
  import os
  from fnmatch import fnmatch
  import win32com.client
  import zipfile, re
  def listallfiles2(n):
  root = 'C:\Cand_Res'
  pattern = *.doc
  list1=[]
  for path, subdirs, files in os.walk(root):
  for name in files:
  if fnmatch(name, pattern):
  file_name1=os.path.join(path, name)
  if .doc in file_name1:
  #EXTRACTING ONLY .DOC FILES
  if .docx not in file_name1:
  #print It is A Doc file$$:,file_name1
  try:
  doc = win32com.client.GetObject(file_name1)
  text = doc.Range().Text
  text1=text.encode('ascii','ignore')
  text_word=text1.split()
  #print Text for Document File Is:,text1
  list1.append(text_word)
  print It is a Doc file
  except:
  print DOC ISSUE
  
  But it seems it is taking too much of time, to convert to text and to
  append to list. Is there any way I may do it fast? I am using Python2.7 on
  Windows 7 Professional Edition. Apology for any indentation error.
  
  If any one may kindly suggest a solution.
 
 It will not help the first time through your documents, but if you write the 
 words for the word documents in one .txt file per .doc, and the original 
 files rarely change you can read from the .txt files when you run your 
 script a second time. Just make sure that the .txt is younger than the 
 corresponding .doc by checking the file time.
 
 In short: use a caching strategy.

Thanks Peter. I'll surely check on that. Regards, Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Problem in Handling MySql Data.

2015-05-02 Thread subhabrata . banerji
Dear Group,

I am trying to write the following script to call around 0.3 million files from 
a remote server. 
It is generally working fine, but could work only upto 65 to 70 files. After 
this, it is just
printing the file names and not processing anything. If anyone may kindly 
suggest what I am
doing wrong?


import pymysql
import pymysql.cursors
import os
import win32com.client
from gensim.models import Word2Vec
import nltk
from nltk.corpus import stopwords
import pyPdf
from pyth.plugins.rtf15.reader import Rtf15Reader
from pyth.plugins.plaintext.writer import PlaintextWriter
import nltk
import zipfile, re
import time

#READING ONE DOC FILE FROM REMOTE LOCATION
def readfilesq9(n):
connection = pymysql.connect(host='xxx.xxx.x.xxx',
 user='abcd',
 passwd='pwd1',
 db='rep_db',
 charset='utf8mb4',
 cursorclass=pymysql.cursors.DictCursor)
list1=[]
with connection.cursor() as cursor:
# Read a single record
sql = SELECT candidateid,cnd.FirstName, 
cnd.LastName,Concat('\\xxx.xxx.x.xxx\File\Cand_Res/',orgguid,'/',DATE_FORMAT(cnd.createddate,'%Y%m'),'/',candidateguid,'/',Resume)
 as ResumePath  from candidate cnd join mstorganization org on cnd.orgid = 
org.OrgId where Resume  '' and Resume is not null order by cnd.modifieddate 
limit 10
cursor.execute(sql)
result = cursor.fetchall()
#print result
#list1=[]
for i in result:
try:
#print i
item_1=i.items()
item_2=item_1[2][1]
print item_2
item_3=item_2.index(/)
file1=item_2[item_2:]
string1='xxx.xxx.x.xxx\\Resumes\\Cand_Res'
file1e=file1.encode('ascii', 'ignore')
urls=file1e.replace(/,\\)
file_full=string1+urls
time.sleep(1)
#osp=C:\\Python27
os1=os.path.abspath(os.curdir)
osp2=os.path.join(os1,file_full)
print Path1:,osp2
file_name1=osp2
print Path:,file_name1
#IDENTIFICATION OF FILE KIND
#DOC CONVERSION
if .doc in file_name1:
#EXTRACTING ONLY .DOC FILES
if .docx not in file_name1:
#print It is A Doc file$$:,file_name
try:
doc = win32com.client.GetObject(file_name1)
text = doc.Range().Text
text1=text.encode('ascii','ignore')
text_word=text1.split()
#print The Text Word is:,text_word
#print Text for Document File Is:,text1
list1.append(text_word)
#print List for Doc File Is:,list3
#print It is a Doc file
except:
print DOC ISSUE
#EXTRACTING ONLY .DOCX FILES
elif .docx in file_name1:
#print It is DOCX FILE:,file_name
docx1=zipfile.ZipFile(file_name1)
content = 
docx1.read('word/document.xml').decode('utf-8')
cleaned = 
re.sub('(.|\n)*?','',content).encode('ascii','ignore')
cleaned_word=cleaned.split()
#print The Cleaned Document Is:,cleaned
list1.append(cleaned_word)
#print List for DocX file Is:,list4
else:
print NONE1
else:
print It is not a Doc file 


except:
print OOPS1

I am using Python2.7.6 on Enthought Canopy. It is not my default Python. My 
default Python is in location,C:\\Python27.
I am using MySql and Windows 7 Professional. Apology for any indentation error.

Regards,
Subhabrata Banerjee. 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fast way of extracting files from various folders

2015-05-02 Thread subhabrata . banerji
On Friday, May 1, 2015 at 5:58:50 PM UTC+5:30, subhabrat...@gmail.com wrote:
 Dear Group,
 
 I have several millions of documents in several folders and subfolders in my 
 machine.
 I tried to write a script as follows, to extract all the .doc files and to 
 convert them in text, but it seems it is taking too much of time. 
 
 import os
 from fnmatch import fnmatch
 import win32com.client
 import zipfile, re
 def listallfiles2(n):
 root = 'C:\Cand_Res'
 pattern = *.doc
 list1=[]
 for path, subdirs, files in os.walk(root):
 for name in files:
 if fnmatch(name, pattern):
 file_name1=os.path.join(path, name)
 if .doc in file_name1:
 #EXTRACTING ONLY .DOC FILES
 if .docx not in file_name1:
 #print It is A Doc file$$:,file_name1
 try:
 doc = win32com.client.GetObject(file_name1)
 text = doc.Range().Text
 text1=text.encode('ascii','ignore')
 text_word=text1.split()
 #print Text for Document File Is:,text1
 list1.append(text_word)
 print It is a Doc file
 except:
 print DOC ISSUE
 
 But it seems it is taking too much of time, to convert to text and to append 
 to list. Is there any way I may do it fast? I am using Python2.7 on Windows 7 
 Professional Edition. Apology for any indentation error. 
 
 If any one may kindly suggest a solution.
 
 Regards,
 Subhabrata Banerjee.

Thanks. You are right conversions are taking time. I would surely check. Rest 
part is okay. Regards, Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Fast way of extracting files from various folders

2015-05-01 Thread subhabrata . banerji
Dear Group,

I have several millions of documents in several folders and subfolders in my 
machine.
I tried to write a script as follows, to extract all the .doc files and to 
convert them in text, but it seems it is taking too much of time. 

import os
from fnmatch import fnmatch
import win32com.client
import zipfile, re
def listallfiles2(n):
root = 'C:\Cand_Res'
pattern = *.doc
list1=[]
for path, subdirs, files in os.walk(root):
for name in files:
if fnmatch(name, pattern):
file_name1=os.path.join(path, name)
if .doc in file_name1:
#EXTRACTING ONLY .DOC FILES
if .docx not in file_name1:
#print It is A Doc file$$:,file_name1
try:
doc = win32com.client.GetObject(file_name1)
text = doc.Range().Text
text1=text.encode('ascii','ignore')
text_word=text1.split()
#print Text for Document File Is:,text1
list1.append(text_word)
print It is a Doc file
except:
print DOC ISSUE

But it seems it is taking too much of time, to convert to text and to append to 
list. Is there any way I may do it fast? I am using Python2.7 on Windows 7 
Professional Edition. Apology for any indentation error. 

If any one may kindly suggest a solution.

Regards,
Subhabrata Banerjee. 

-- 
https://mail.python.org/mailman/listinfo/python-list


Accessing file from Remote location

2015-04-29 Thread subhabrata . banerji
Dear Group,

I have a good amount of data in a remote location. 
It is in MySql Database. I am trying to access it as,
 import pymysql
 import pymysql.cursors
...
...
with connection.cursor() as cursor:
# Read a single record
sql = SELECT candidateid,cnd.FirstName, 
cnd.LastName,Concat('\\xxx.xxx.x.xxx\files\Cand_Res/',orgguid,'/',DATE_FORMAT(cnd.createddate,'%Y%m'),'/',candidateguid,'/',File)
 as filePath  from candidate cnd join mstorganization org on cnd.orgid = 
org.OrgId order by cnd.modifieddate limit 1
cursor.execute(sql)
result = cursor.fetchone()
print(result)

Now I am getting the file path.

I am trying to open this file in Python.

I tried options as, 
f=open(//remote_machine/folder1/file1.doc, r),
f=open(remote_machine\\folder1\\file1.doc, r)
...

given in 
https://mail.python.org/pipermail/python-win32/2009-February/008847.html
and in
http://www.thecodingforums.com/threads/how-to-open-a-remote-file-using-python.671892/

but I am not being able to open it. 

Am I doing any error? 

If I run the path I am getting the document.

My document path is:
\\xxx.xxx.x.xxx\Files\Cand_Res/0FB45CD9-B9E3-4ED5-BBD0-B0EA3DA62B2E/201308/da0791ba-b123-4cfc-ac1e-5a42af2091d8/2f14e4b3-4fb8-4e5f-bcb8-f5d34ee9ab8d.doc

I am using Python 2.7.6 | 64-bit | (default, Sep 15 2014, 17:36:35) [MSC v.1500 
64 bit (AMD64)] on win32 Enthought
Canopy. This is not my default Python location. 
My current directory is:
 os.getcwd()
'C:\\Windows\\system32'
 

I am using Windows 7 Professional 64 bit. 

If any body may kindly suggest. 

Regards,
Subhabrata Banerjee. 











-- 
https://mail.python.org/mailman/listinfo/python-list


Boolean Operator Confusion

2015-04-24 Thread subhabrata . banerji
Dear Group,

I am trying to understand the use of Boolean operator in Python. I am trying to 
write small piece of script, as follows,

def input_test():
str1=raw_input(PRINT QUERY:)
if AND or OR or NOT in str1:
print It is a Boolean Query
elif AND or OR or NOT not in str1:
print It is not a Boolean Query
else:
print None

I am trying to achieve if the words AND,OR,NOT ... in string I want to 
recognize it as,
Boolean Query, if they are not there the string is not Boolean query. 
As I am trying to test it I am getting following output,

 input_test()
PRINT QUERY:obama AND clinton
It is a Boolean Query
 input_test()
PRINT QUERY:obama clinton
It is a Boolean Query

To understand Boolean operators I have tried to read the follwing link,
https://docs.python.org/release/2.5.2/lib/boolean.html

and practised script like the following:
 def currency(n):
x1=raw_input(PRINT Your Country)
x2=raw_input(Print Your Currency)
if x1==USA and x2==Dollar:
print Correct
elif x1==USA and x2!=Dollar:
print Not Matching
else:
print None


 currency(1)
PRINT Your CountryUSA
Print Your CurrencyDollar
Correct


But I am doing something wrong. If anybody may kindly suggest.

Regards,
Subhabrata Banerjee.
 






-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Boolean Operator Confusion

2015-04-24 Thread subhabrata . banerji
On Friday, April 24, 2015 at 8:45:04 PM UTC+5:30, Steven D'Aprano wrote:
 On Sat, 25 Apr 2015 12:50 am,wrote:
 
  Dear Group,
  
  I am trying to understand the use of Boolean operator in Python. I am
  trying to write small piece of script, as follows,
  
  def input_test():
  str1=raw_input(PRINT QUERY:)
  if AND or OR or NOT in str1:
  print It is a Boolean Query
  elif AND or OR or NOT not in str1:
  print It is not a Boolean Query
  else:
  print None
 
 First problem: why do you sometimes return None? You have two possible
 answers: either something is a boolean query, or it is not. There is no
 third choice. (It's a boolean query, but only on Wednesdays.)
 
 So your code you have if...else and no elif needed.
 
 if test for boolean query:
 print It is a Boolean Query
 else:
 print It is not a Boolean Query
 
 
 Now let us look at your test for a boolean query:
 
 AND or OR or NOT in str1
 
 
 How does a human reader understand that as English?
 
 if AND is in the string, or OR is in the string, or NOT 
 is in the string, then it is a boolean query.
 
 But sadly, that is not how Python sees it. Python sees it as:
 
 if AND is a true value, or if OR is a true value, 
 or if NOT is in the string, then it is a boolean query.
 
 AND is always a true value. All strings except for the empty string  are
 true values, so expressions like:
 
 if X or Y or Z in some_string
 
 will always be true, if X or Y are true values.
 
 You need to re-write your test to be one of these:
 
 # version 1
 if AND in str1 or OR in str1 or NOT in str1:
 print It is a Boolean Query
 else:
 print It is not a Boolean Query
 
 
 # version 2
 if any(word in str1 for word in (AND, OR, NOT)):
 print It is a Boolean Query
 else:
 print It is not a Boolean Query
 
 
 
 
 -- 
 Steven

Thanks Steven for taking so much of your valuable time to make me understand 
and nice guidance. Ian your suggestion worked well. Thank you. Regards, 
Subhabrata Banerjee.
-- 
https://mail.python.org/mailman/listinfo/python-list


Boolean Search using Strings

2015-04-23 Thread subhabrata . banerji
Dear Group,

I want to do the Boolean search over various sentences or documents.
I do not want to use special programs like Whoosh, etc.
May I use any other parser?
If anybody may kindly let me know.

Regards,
Subhabrata Banerjee. 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: May I drop list bracket from list?

2015-04-23 Thread subhabrata . banerji
On Thursday, April 23, 2015 at 3:57:28 PM UTC+5:30, Peter Otten wrote:
 
 
  Dear Group,
  
  I am trying to read a list of files as
  list_of_files = glob.glob('C:\Python27\*.*')
  Now I am trying to read each one of them,
  convert into list of words, and append to a list
  as.
  
  list1=[]
  for file in list_of_files:
print file
fread1=open(file,r).read()
fword=fread1.split()
list1.append(fword)
  
  Here the list is a list of lists, but I want only one list not
  list of lists.
  
  I was thinking of stripping it as, str(list1).strip('[]')
  
  but in that case it would be converted to string.
  
  Is there a way to do it. I am using Python27 on Windows7 Professional.
  Apology for an indentation error.
  
  If anybody may please suggest.
 
 You have to understand that the append() method always appends a single item 
 to the list, be that a string or a list or whatever. If you want to append 
 words in a list to the list the logical approach is therefore to loop over 
 the words and invoke append for every word
 
 for word in fword:
 list1.append(word)
 
 There is also a dedicated extend() method that takes a list (actually an 
 iterable) and appends all items in that list:
 
 list1.extend(fword)

Thanks Peter. I tried an example,
 ll = [['a'], ['b'], ['c']]
 l = [x for y in ll for x in y]

I would try your one,too.

Regards,
Subhabrata Banerjee. 

-- 
https://mail.python.org/mailman/listinfo/python-list


May I drop list bracket from list?

2015-04-23 Thread subhabrata . banerji
Dear Group, 

I am trying to read a list of files as 
list_of_files = glob.glob('C:\Python27\*.*')
Now I am trying to read each one of them, 
convert into list of words, and append to a list
as.

list1=[]
for file in list_of_files:
  print file
  fread1=open(file,r).read()
  fword=fread1.split()
  list1.append(fword)

Here the list is a list of lists, but I want only one list not 
list of lists.

I was thinking of stripping it as, str(list1).strip('[]')

but in that case it would be converted to string.

Is there a way to do it. I am using Python27 on Windows7 Professional.
Apology for an indentation error. 

If anybody may please suggest. 

Regards,
Subhabrata Banerjee. 




  

  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Opening Multiple files at one time

2015-04-22 Thread subhabrata . banerji
On Monday, April 20, 2015 at 5:30:15 PM UTC+5:30, subhabrat...@gmail.com wrote:
 Dear Group,
 
 I am trying to open multiple files at one time. 
 I am trying to do it as,
 
  for item in  [ one, two, three ]:
f = open (item + world.txt, w)
f.close()
 
 This is fine. But I was looking if I do not know the number of
 text files I would create beforehand, so not trying xrange option
 also. 
 
 And if in every run of the code if the name of the text files have
 to created on its own. 
 
 Is there a solution for this? 
 
 If anybody may please suggest. 
 
 Regards,
 Subhabrata Banerjee.

Surely, this problem is more or less fixed. But I experiment with all answers 
everytime to get better angles.
-- 
https://mail.python.org/mailman/listinfo/python-list


A question on the creation of list of lists

2015-04-22 Thread subhabrata . banerji
Dear Group,

I am trying to open a bunch of files from a directory and trying to put the 
results in list of lists that is to say,

that is to say, 
I have a list of file names of a directory, I want to read each one of them. 
After reading each one of them, I want to put the results of each file in a 
list. 
These lists would again be inserted to create a list of lists.

to do this I am trying to write it as follows:

list_of_files = glob.glob('C:\Python27\*.*')
print list_of_files
list1=[]
list2=[]
list_N=[list1,list2]
for i,j in zip(list_of_files,list_N):
print i,j
x1=open(i,r).read()
x2=j.append(x1)
all_sent=list_N
print all_sent

Am I doing anything wrong? If any one may kindly suggest?
Is there any smarter way to do it? I am using Python2.7+
on MS-Windows 7 Professional Edition. 
Apology for any indentation error. 

Regards,
Subhabrata Banerjee.






-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A question on the creation of list of lists

2015-04-22 Thread subhabrata . banerji
On Wednesday, April 22, 2015 at 9:48:44 PM UTC+5:30, subhabrat...@gmail.com 
wrote:
 Dear Group,
 
 I am trying to open a bunch of files from a directory and trying to put the 
 results in list of lists that is to say,
 
 that is to say, 
 I have a list of file names of a directory, I want to read each one of them. 
 After reading each one of them, I want to put the results of each file in a 
 list. 
 These lists would again be inserted to create a list of lists.
 
 to do this I am trying to write it as follows:
 
 list_of_files = glob.glob('C:\Python27\*.*')
 print list_of_files
 list1=[]
 list2=[]
 list_N=[list1,list2]
 for i,j in zip(list_of_files,list_N):
 print i,j
 x1=open(i,r).read()
 x2=j.append(x1)
 all_sent=list_N
 print all_sent
 
 Am I doing anything wrong? If any one may kindly suggest?
 Is there any smarter way to do it? I am using Python2.7+
 on MS-Windows 7 Professional Edition. 
 Apology for any indentation error. 
 
 Regards,
 Subhabrata Banerjee.

I was trying to get some results over small data before putting heavy data, code
seems giving desired output, as in 

The name of files are: ['C:\\Python27\\TestDoc\\TestDoc1.txt', 
'C:\\Python27\\TestDoc\\TestDoc2.txt', 'C:\\Python27\\TestDoc\\TestDoc3.txt', 
'C:\\Python27\\TestDoc\\TestDoc4.txt']
C:\Python27\TestDoc\TestDoc1.txt []
C:\Python27\TestDoc\TestDoc2.txt []
C:\Python27\TestDoc\TestDoc3.txt []
C:\Python27\TestDoc\TestDoc4.txt []
The Contents of file in list of lists: [['There is a home.'], ['One man lives 
there.'], ['He is tall.'], ['He is good.']]

I am trying to put heavy files with big contents, so was getting confused 
whether I was going fine. But the way I am creating lists may there be a a 
better way? 

Regards,
Subhabrata Banerjee. 



 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Opening Multiple files at one time

2015-04-21 Thread subhabrata . banerji
On Tuesday, April 21, 2015 at 4:20:16 AM UTC+5:30, Dave Angel wrote:
 On 04/20/2015 07:59 AM,  wrote:
  Dear Group,
 
  I am trying to open multiple files at one time.
  I am trying to do it as,
 
for item in  [ one, two, three ]:
  f = open (item + world.txt, w)
  f.close()
 
  This is fine.
 
 But it does not open multiple files at one time.  Perhaps you'd better 
 explain better what you mean by at one time.
 
  But I was looking if I do not know the number of
  text files I would create beforehand,
 
 So instead of using a literal list [ one, two... ]
 you construct one, or read it in from disk, or use sys.argv.  What's the 
 difficulty?  Nothing in the code fragment you show cares how long the 
 list is.
 
 
   so not trying xrange option
  also.
 
 No idea what the xrange option means.
 
 
  And if in every run of the code if the name of the text files have
  to created on its own.
 
 So figure out what you're going to use for those names, and write the 
 code to generate them.
 
 
  Is there a solution for this?
 
 For what?
 
 
 -- 
 DaveA

Yes. They do not. They are opening one by one. 
I have some big chunk of data I am getting by crawling etc.
now as I run the code it is fetching data. 
I am trying to fetch the data from various sites.
The contents of the file are getting getting stored in 
separate files. 
For example, if I open the site of http://www.theguardian.com/international;, 
then the result may be stored in file in file file1.txt, and the contents of 
site http://edition.cnn.com/;, may be stored in file file2.txt. 

But the contents of each site changes everyday. So everyday as you open these 
sites and store the results, you should store in different text files. These 
text files I am looking to be created on its own, as you do not know its 
numbers, how many numbers you need to fetch the data. 

I am trying to do some results with import datetime as datetime.datetime.now()
may change everytime. I am trying to put it as name of file. But you may 
suggest better. 

Regards,
Subhabrata Banerjee.
-- 
https://mail.python.org/mailman/listinfo/python-list


Opening Multiple files at one time

2015-04-20 Thread subhabrata . banerji
Dear Group,

I am trying to open multiple files at one time. 
I am trying to do it as,

 for item in  [ one, two, three ]:
   f = open (item + world.txt, w)
   f.close()

This is fine. But I was looking if I do not know the number of
text files I would create beforehand, so not trying xrange option
also. 

And if in every run of the code if the name of the text files have
to created on its own. 

Is there a solution for this? 

If anybody may please suggest. 

Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Converting text file to different encoding.

2015-04-17 Thread subhabrata . banerji
I am having few files in default encoding. I wanted to change their encodings, 
preferably in UTF-8, or may be from one encoding to any other encoding. 

I was trying it as follows,

import codecs
sourceEncoding = iso-8859-1
targetEncoding = utf-8
source = open(source1,w)
target = open(target, w)
target.write(unicode(source, sourceEncoding).encode(targetEncoding))

but it was giving me error as follows,
Traceback (most recent call last):
  File pyshell#6, line 1, in module
target.write(unicode(source, sourceEncoding).encode(targetEncoding))
TypeError: coercing to Unicode: need string or buffer, file found

If anybody may kindly suggest how may I solve it. 

Regards,
Subhabrata Banerjee. 
 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Converting text file to different encoding.

2015-04-17 Thread subhabrata . banerji
On Friday, April 17, 2015 at 6:50:08 PM UTC+5:30, subhabrat...@gmail.com wrote:
 I am having few files in default encoding. I wanted to change their 
 encodings, 
 preferably in UTF-8, or may be from one encoding to any other encoding. 
 
 I was trying it as follows,
 
 import codecs
 sourceEncoding = iso-8859-1
 targetEncoding = utf-8
 source = open(source1,w)
 target = open(target, w)
 target.write(unicode(source, sourceEncoding).encode(targetEncoding))
 
 but it was giving me error as follows,
 Traceback (most recent call last):
   File pyshell#6, line 1, in module
 target.write(unicode(source, sourceEncoding).encode(targetEncoding))
 TypeError: coercing to Unicode: need string or buffer, file found
 
 If anybody may kindly suggest how may I solve it. 
 
 Regards,
 Subhabrata Banerjee.

As an ace coder you may know better than me what I would need, but if you have 
any roundabout or hint you may give I will practice to see if I may port it. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Converting text file to different encoding.

2015-04-17 Thread subhabrata . banerji
On Friday, April 17, 2015 at 7:36:46 PM UTC+5:30, Oscar Benjamin wrote:
  wrote:
  On Friday, April 17, 2015 at 6:50:08 PM UTC+5:30,  wrote:
  I am having few files in default encoding. I wanted to change their 
  encodings,
  preferably in UTF-8, or may be from one encoding to any other encoding.
 
  I was trying it as follows,
 
  import codecs
  sourceEncoding = iso-8859-1
  targetEncoding = utf-8
  source = open(source1,w)
  target = open(target, w)
  target.write(unicode(source, sourceEncoding).encode(targetEncoding))
 
  but it was giving me error as follows,
  Traceback (most recent call last):
File pyshell#6, line 1, in module
  target.write(unicode(source, sourceEncoding).encode(targetEncoding))
  TypeError: coercing to Unicode: need string or buffer, file found
 
 The error comes from `unicode(source, sourceEncoding)` and results
 from the fact that source is a file object when it should be a string.
 To read the contents of the file as a string just change `source` to
 `source.read()`.
 
 
 Oscar

I tried to do as follows,
 import codecs
 sourceEncoding = iso-8859-1
 targetEncoding = utf-8
 source = open(source1,w)
 string1=String type
 str1=str(string1)
 source.write(str1)
 source.close()
 target = open(target, w)
 source=open(source1,r)
 target.write(unicode(source.read(), sourceEncoding).encode(targetEncoding))


am I going ok?

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to convert .doc file to .txt in Python

2015-04-09 Thread subhabrata . banerji
On Thursday, April 9, 2015 at 4:23:55 PM UTC+5:30, Tim Golden wrote:
 On 09/04/2015 11:25, wrote:
  Dear Group,
  
  I was trying to convert .doc file to .txt file.
  
  I got of python-docx, zipfile but they do not seem to help me much.
  
  You may kindly suggest how to convert from .doc to
  .docx/.html/.pdf/.rtf as from them I am being able to convert to
  .txt.
  
  If any one of the Python experts may kindly help me.
 
 
 There are several approaches, but this one will work (assuming you are
 on Windows and have the pywin32 package installed):
 
 code
 import os
 import win32com.client
 
 DOC_FILEPATH = c:/temp/something.docx
 doc = win32com.client.GetObject(DOC_FILEPATH)
 text = doc.Range().Text
 
 #
 # do something with the text...
 #
 with open(something.txt, wb) as f:
   f.write(text.encode(utf-8))
 
 os.startfile(something.txt)
 
 /code
 
 TJG

Thanks Tim it is slightly better than my solution. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to convert .doc file to .txt in Python

2015-04-09 Thread subhabrata . banerji
On Thursday, April 9, 2015 at 3:56:09 PM UTC+5:30, subhabrat...@gmail.com wrote:
 Dear Group,
 
 I was trying to convert .doc file to .txt file. 
 
 I got of python-docx, zipfile but they do not seem to help me much. 
 
 You may kindly suggest how to convert from .doc to .docx/.html/.pdf/.rtf as 
 from them I am being able to convert to .txt. 
 
 If any one of the Python experts may kindly help me. 
 
 Regards,
 Subhabrata Banerjee.

I could do one it seems running with 
 import win32com.client as win32
 word = win32.Dispatch(Word.Application)
 word.Visible = 0
 word.Documents.Open(/python27/Document1.doc)
COMObject Open
 doc = word.ActiveDocument

seems working. You may suggest better. 
-- 
https://mail.python.org/mailman/listinfo/python-list


How to convert .doc file to .txt in Python

2015-04-09 Thread subhabrata . banerji
Dear Group,

I was trying to convert .doc file to .txt file. 

I got of python-docx, zipfile but they do not seem to help me much. 

You may kindly suggest how to convert from .doc to .docx/.html/.pdf/.rtf as 
from them I am being able to convert to .txt. 

If any one of the Python experts may kindly help me. 

Regards,
Subhabrata Banerjee.  
-- 
https://mail.python.org/mailman/listinfo/python-list


How to handle file in Whoosh?

2015-03-31 Thread subhabrata . banerji
I am trying to build a search engine, I started with Whoosh. The tutorial and 
web based materials are fine. Web has sizable question and answers. The initial 
experiments seem going fine. But I want to handle files located in various 
parts of my machine. I found from whoosh.filedb.filestore import FileStorage, 
but I am looking for a simple example to start with. I tried something as 
below, it may be giving some result but is it going okay? If any one may please 
see and correct if required?

 txt_file1=open(/python27/whooshtext1.txt,r).read()
 txt_file2=open(/python27/whooshtext3.txt,r).read()
 writer.add_document(title=uFirst document, path= 
 unicode(indexdir+os.sep+a),content=utxt_file1)
 writer.add_document(title=uSecond document, path= 
 unicode(indexdir+os.sep+b),content=utxt_file2)
 writer.commit()
 with ix.searcher() as searcher:
query = QueryParser(content, ix.schema).parse(flood)
results = searcher.search(query)
print results
for result in results:
print result


Top 0 Results for Term('content', u'flood') runtime=0.000124042337439
 
-- 
https://mail.python.org/mailman/listinfo/python-list


Enthought Canopy

2015-03-19 Thread subhabrata . banerji
Hi,

I was trying to download Python2.7 in a new machine. I found Python2.7.9. 
I tried to install few libraries like Numpy, Sympy, Scipy, NLTK etc. 
I was trying to use http://www.lfd.uci.edu/~gohlke/pythonlibs/ to download the 
libraries. 
Initially there were some problems to download Numpy. 
So tried to get Canopy from 
https://www.enthought.com/products/canopy/package-index/,
and found it also has IDLE as GUI. 
I found numpy, scipy there. 

Now I saw if I install the .whl files I can install it in Canopy and use it 
from the IDLE available there. 

These files are not getting installed in my original Python library and I am 
not finding them in the original Python GUI. 

May I use Enthought based Python2.7 and its associated GUI for developing 
software or should I migrate and use the Python2.7 library and its associated 
GUI?

If anyone of the members may kindly suggest. 

Regards,
Subhabrata. 
  

-- 
https://mail.python.org/mailman/listinfo/python-list