Re: Datetime objects

2006-08-02 Thread Rama
I am a newcomer to python - so not too sure if this method is the correct one.
 
Noticing this,
 
>>> dir(diff)['__abs__', '__add__', '__class__', '__delattr__', '__div__', '__doc__', '__eq__', '__floordiv__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__mul__', '__ne__', '__neg__', '__new__', '__nonzero__',
 '__pos__', '__radd__', '__rdiv__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rmul__', '__rsub__', '__setattr__', '__str__', '__sub__', 'days', 'max', 'microseconds', 'min', 'resolution', 'seconds']

 
it seems 
 
>>> diff.seconds52662
 
should give you what you want. Converting the seconds to hours, minutes, seconds should be easy.
 
Of course, looking at help(diff), I get the impression that in the generic case you should check if diff.days == 0 to decide if you should be usingthat as well.
 
thank,
Rama
 
On 2 Aug 2006 05:16:08 -0700, Lad <[EMAIL PROTECTED]> wrote:
Sybren Stuvel wrote:> Lad enlightened us with:> > How can I find days and minutes difference between two datetime
> > objects?> > For example If I  have> > b=datetime.datetime(2006, 8, 2, 8, 57, 28, 687000)> > a=datetime.datetime(2006, 8, 1, 18, 19, 45, 765000)>> diff = b - a
Ok, I tried>>> diff=b-a>>> diffdatetime.timedelta(0, 52662, 922000)>>> diff.mindatetime.timedelta(-9)which is not good for me.So I tried to use toordinal like this
diff=b.toordinal()-a.toordinal()but I getdiff=1Why?where do I make a mistake?Thank you for help--http://mail.python.org/mailman/listinfo/python-list

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

Re: Datetime question

2006-08-03 Thread Rama
the datetime object appears to have a replace method which could achieve what you want to do, albeith with some computation from your end first,
 
>>> d = datetime.datetime(2006, 8, 3, 14, 13, 56, 609000)>>> dir(d)['__add__', '__class__', '__delattr__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__ne
w__', '__radd__', '__reduce__', '__reduce_ex__', '__repr__', '__rsub__', '__setattr__', '__str__', '__sub__', 'astimezone', 'combine', 'ctime', 'date', 'day', 'dst', 'fromordinal', 'fromtimestamp', 'hour', 'isocalendar', 'isoformat', 'isowe
ekday', 'max', 'microsecond', 'min', 'minute', 'month', 'now', 'replace', 'resolution', 'second', 'strftime', 'time', 'timetuple', 'timetz', 'today', 'toordinal', 'tzinfo', 'tzname', 'utcfromtimestamp', 'utcnow', 'utcoffset', 'utctimetuple'
, 'weekday', 'year']>>> d.replace(year=2007)datetime.datetime(2007, 8, 3, 14, 13, 56, 609000)>>>
 
thanks,
Rama
 
On 3 Aug 2006 05:26:31 -0700, Lad <[EMAIL PROTECTED]> wrote:
In a datetime object I would like to change days and hours.Or in other words, I would like to copy this datetime object but
increase days and hours.Is it possible?For example:If I have a datetime object like thisdatetime.datetime(2006, 8, 3, 14, 13, 56, 609000)I would like to make a new ,for example like thisdatetime.datetime
(2006, 8, 12, 10, 13, 56, 609000)is it possible to do so?Thank youL--http://mail.python.org/mailman/listinfo/python-list

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

Re: Datetime question

2006-08-03 Thread Rama

> In a datetime object I would like to change days and hours.you'd been pointed to the resources yesterday - please read manuals
carefully!a = datetime.datetime(2006, 8, 12, 10, 13, 56, 609000)b = a + datetime.timedelta(days=-2, hours=-4)
 

   
But wont this create a new object? Whereas if you want to modify the same object, should we not be using replace? Or does it not matter in the global picture?
 
>>> a = datetime.datetime(2006, 8, 12, 10, 13, 56, 609000)>>> b = a + datetime.timedelta(days=-2, hours=-4)>>>>>>>>> id(a)21838592>>> id(b)
21836312>>> a.replace(day=a.day + 1)datetime.datetime(2006, 8, 13, 10, 13, 56, 609000)>>> id(a)21838592>>>
 

 
thanks,
Rama
 
   
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Datetime question

2006-08-03 Thread Rama
datetime objects are immutable. You can't change the value of anexisting datetime object, only create a new one.

 
 
Um.. then how do I get the same ID when I call the replace method?
 
 
>>> a = datetime.datetime(2006, 8, 12, 10, 13, 56, 609000)>>> b = a + datetime.timedelta(days=-2, hours=-4)>>>>>>
>>> id(a)21838592>>> id(b) 21836312>>> a.replace(day=a.day + 1)datetime.datetime(2006, 8, 13, 10, 13, 56, 609000)>>> id(a)21838592>>>

 
thanks,
Rama 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Datetime question

2006-08-03 Thread Rama
Ah, true. Sorry. I got thrown by the ouput after the line got executed and assumed it was the value of a.
 
thanks,
Rama
 
On 03/08/06, Simon Brunning <[EMAIL PROTECTED]> wrote:
On 8/3/06, Rama <[EMAIL PROTECTED]> wrote:
> Just curious why when> I call id(a) I get the same id after I call the replace method.In your example, you called a's replace() method, but did nothing withthe new datetime object that it returned. The original object, a,
naturally still has the same ID, but it also still has the same value.--Cheers,Simon B,[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list

Getting Process Name on Win32

2006-09-06 Thread Rama
Hi,  I want to list the names of all the processes running on my machine. I am stuck at this point and do not know how to extract the name of a process. Using win32process.EnumProcesses, I am able to obtain the pids of all the processes and using 
win32api.OpenProcess() I have obtained a handle to the process. However, I could not find an appropriate method to provide me the name of the process. I went through the available documentation on the 
http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/pywin32/win32.html site - but could not find something to help me. Could some one please guide me on this? thanks,Rama
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Getting Process Name on Win32

2006-09-06 Thread Rama
On 06/09/06, Tim Golden <[EMAIL PROTECTED]> wrote:
[Rama]|  I want to list the names of all the processes running on| my machine. I am stuck at this point and do not know how to| extract the name of a process.WMI is good for this kind of thing:
http://tgolden.sc.sabren.com/python/wmi_cookbook.html#running_processesAwesome. That works for me.
Just curious, however - is there any way at all to get this through the win32* modules? I notice that there is a Windows API - QueryFullProcessImageName - but I don't see this in these modules (or maybe I am not looking closely enought).
thanks,Rama
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: newbe who is also senior having a senior moment

2006-09-06 Thread Rama
On 07/09/06, stan <[EMAIL PROTECTED]> wrote:
File "C:\Python24\2L file for iTunes", line 4, in -toplevel-import win32com.clientImportError: No module named win32com.clientcan someone pls point me in the right direction here as I am trying to
urgently fix the file for someones birthday in game (I know pathetic)Try installing the python for win32 extensions - http://starship.python.net/crew/mhammond/win32/
thanks,Rama
-- 
http://mail.python.org/mailman/listinfo/python-list

UnicodeEncode Error ?

2009-03-11 Thread Rama Vadakattu
While doing the below

1) fetch  html page
2) extract title using BeatifulSoup
3) Save into the database.

iam getting the below error (at the bottom).

Few observations which i had:
 1) type of variable which holds this title is 
 2) iam getting this problem when the title has character whose
ordinal value > 128

I searched in google and tried various suggestions but none of them is
working.And also i couldnot able to understand the rootcause for such
a kind of behaviour.

What will be the root cause for such a kind of problem?Any hint on how
to resolve this error?

~~~
Error
--
Traceback (most recent call last):
  File "fetchcron.py", line 11, in 
cmanager.triggerfetchFeed()
  File "/home/rama/djangoprojects/socialreader/views.py", line 40, in
triggerfetchFeed
self.fetchFeed(furl)
  File "/home/rama/djangoprojects/socialreader/views.py", line 102, in
fetchFeed
ne.save()
  File "/usr/lib/python2.5/site-packages/django/db/models/base.py",
line 311, in save
self.save_base(force_insert=force_insert,
force_update=force_update)
  File "/usr/lib/python2.5/site-packages/django/db/models/base.py",
line 383, in save_base
result = manager._insert(values, return_id=update_pk)
  File "/usr/lib/python2.5/site-packages/django/db/models/manager.py",
line 138, in _insert
return insert_query(self.model, values, **kwargs)
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
line 894, in insert_query
return query.execute_sql(return_id)
  File "/usr/lib/python2.5/site-packages/django/db/models/sql/
subqueries.py", line 309, in execute_sql
cursor = super(InsertQuery, self).execute_sql(None)
  File "/usr/lib/python2.5/site-packages/django/db/models/sql/
query.py", line 1734, in execute_sql
cursor.execute(sql, params)
  File "/usr/lib/python2.5/site-packages/django/db/backends/util.py",
line 19, in execute
return self.cursor.execute(sql, params)
  File "/usr/lib/python2.5/site-packages/django/db/backends/mysql/
base.py", line 83, in execute
return self.cursor.execute(query, args)
  File "/var/lib/python-support/python2.5/MySQLdb/cursors.py", line
151, in execute
query = query % db.literal(args)
  File "/var/lib/python-support/python2.5/MySQLdb/connections.py",
line 247, in literal
return self.escape(o, self.encoders)
  File "/var/lib/python-support/python2.5/MySQLdb/connections.py",
line 180, in string_literal
return db.string_literal(obj)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xc9' in
position 1: ordinal not in range(128)
---
--
http://mail.python.org/mailman/listinfo/python-list


how to get the summarized text from a given URL?

2009-03-24 Thread Rama Vadakattu
Is there any python library to solve the below problem?

FOr the below URL :
--
http://tinyurl.com/dzcwbg

Summarized text is :
---
By Roy Mark With sales plummeting and its smart phones failing to woo
new customers, Sony Ericsson follows its warning that first quarter
sales will be disappointing with the announcement that Najmi Jarwala,
president of Sony Ericsson USA and head of ...

~~
Usually summarized text is a  2 to 3 line description of the URL which
we usually obtain by fetching that html page , examining the  content
and  figuring out short description from that html markup.
~

Are there any python libraries which give summarized text for a given
url ?

It is ok even if the library  just gives  intial two lines of text
from the given URL Instead of summarization.
--
http://mail.python.org/mailman/listinfo/python-list


Why born like human? Read Ramayana & Follow Rama.

2010-02-25 Thread Sree Rama
Why born like human? Read Ramayana & Follow Rama.

Once in a life you should read this great story, read this story in
simple language at

http://ramayanastory-rama.blogspot.com/2010/02/sri-rama-prince-of-ayodhya.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Not able to store data to dictionary because of memory limitation

2011-07-06 Thread Rama Rao Polneni
Hi All,

I am facing a problem when I am storing cursor fetched(Oracle 10G)
data in to a dictionary.
As I don't have option to manipulate data in oracle10G, I had to stick
to python to parse the data for some metrics.

After storing 1.99 GB data in to the dictionary, python stopped to
store the remaining data in to dictionary.

Memory utilization is 26 GB/34GB. That means, still lot memory is left
as unutilized.

Can please share your experices/ideas to resolve this issue.
Is this prople mbecasue of large memory utlization.
Is there any alternate solution to resolve this issue. Like splitting
the dictionaries or writing the data to hard disk instead of writing
to memory.
How efficiently we can use  memory when we are going for dictionaries.

Thanks in advacne,
Rama
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Not able to store data to dictionary because of memory limitation

2011-07-06 Thread Rama Rao Polneni

Yes the data is from table. which is retrieved using some queries in
to cx_oracel cursor.  I am able to read the data row by row.
One more information, I am Able to load the data in to dictionary by
removing some some data from table.

-Ram

> Is the data one row from the table, or could you work with it row-by-row?
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list


On 7/6/11, Chris Angelico  wrote:
> On Wed, Jul 6, 2011 at 5:49 PM, Rama Rao Polneni  wrote:
>> Hi All,
>>
>> I am facing a problem when I am storing cursor fetched(Oracle 10G)
>> data in to a dictionary.
>> As I don't have option to manipulate data in oracle10G, I had to stick
>> to python to parse the data for some metrics.
>>
>> After storing 1.99 GB data in to the dictionary, python stopped to
>> store the remaining data in to dictionary.
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Not able to store data to dictionary because of memory limitation

2011-07-31 Thread Rama Rao Polneni
Hi Ulrich,

Thanks for your idea.
I resolved the issue by making use of integers instead of strings.
Earlier I had many duplicate strings in different rows retrieved from database.
I created a list to have unique strings and their indexes are used in
actual computations. So lot of space is saved by having integers
instead of strings.

I  am trying differnt approach too, to get ids from database instead
of gettign direct values. values will be retrived by using unique ids
of different tables. I hope, I will be able to improve perforamnce
with this approach.

Regards,
Rama

On 7/6/11, Ulrich Eckhardt  wrote:
> Rama Rao Polneni wrote:
>> After storing 1.99 GB data in to the dictionary, python stopped to
>> store the remaining data in to dictionary.
>
> Question here:
>  - Which Python?
>  - "stopped to store" (you mean "stopped storing", btw), how does it behave?
> Hang? Throw exceptions? Crash right away?
>
>
>> Memory utilization is 26 GB/34GB. That means, still lot memory is left
>> as unutilized.
>
> 2GiB is typically the process limit for memory allocations on 32-bit
> systems. So, if you are running a 32-bit system or running a 32-bit process
> on a 64-bit system, you are probably hitting hard limits. With luck, you
> could extend this to 3GiB on a 32-bit system.
>
>
>> Is this proplem becasue of large memory utlization.
>
> I guess yes.
>
>
>> Is there any alternate solution to resolve this issue. Like splitting
>> the dictionaries or writing the data to hard disk instead of writing
>> to memory.
>
> If you have lost of equal strings, interning them might help, both in size
> and speed. Doing in-memory compression would be a good choice, too, like
> e.g. if you have string fields in the DB that can only contain very few
> possible values, converting them to an integer/enumeration.
>
> Otherwise, and this is a more general approach, prefer making a single sweep
> over the data. This means that you read a chunk of data, perform whatever
> operation you need on it, possibly write the results and then discard the
> chunk. This keeps memory requirements low. At first, it doesn't look as
> clean as reading the whole data in one step, calculations as a second and
> writing results as a third, but with such amounts of data as yours, it is
> the only viable step.
>
> Good luck, and I'd like to hear how you solved the issue!
>
> Uli
>
> --
> Domino Laser GmbH
> Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list