Re: Python is overtaking Perl

2007-09-05 Thread digz
On Sep 4, 1:53 pm, "OKB (not okblacke)"
<[EMAIL PROTECTED]> wrote:
> George Sakkis wrote:
> > On Sep 4, 8:35 am, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> >> On Tue, 04 Sep 2007 00:32:23 -, Ben <[EMAIL PROTECTED]>
> >> wrote:
> >> >Here are the statistics from Google Trends:
>
> >> >http://benyang22a.blogspot.com/2007/09/perl-vs-python.html
>
> >> >From the graph, it seems more accurate to say that Perl is
> >> >undertaking Python.
>
> >> Jean-Paul
>
> > And to make it even more accurate, "Perl is undertaking Python in
> > India", since that's where the difference in favor of Python comes
> > from.
>
> No, it's the other way around.  The big difference in India is in
> favor of Perl.
>


I guess India is a big leader in perl coz all the decades old perl
scripts are maintained in India.
US Corporations have outsourced fixing/changing 80s-90s perl code to
India.

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


converting pipe delimited file to fixed width

2009-03-19 Thread digz
Hi,
I am trying to convert a | delimited  file to fixed width by right
padding with spaces, Here is how I have written the program , just get
the feeling this can be done in a much better ( python functional )
way rather than the procedural code i have below . Any help
appreciated

#!/usr/bin/python
def rightFill(fillString, toLength, fillChar):
return fillString+''.join([fillChar for x in range(len
(fillString),toLength)])

fieldWidth=[ 14, 6, 18, 21, 21,4, 6  ];

file = open("/home/chatdi/input.csv", "r");
lines = file.readlines()
file.close()

out = open( "/home/chatdi/ouptut.csv", 'w')
for line in lines:
line = line[:-1]
index = 0
for token in line.split('|'):
paddedToken = rightFill(token, fieldWidth[index], ' ' )
out.write( paddedToken )
index = index + 1
out.write("\n")
--
http://mail.python.org/mailman/listinfo/python-list


problems displaying results in ibm_db

2009-07-01 Thread digz
This simple db connectivity and select test program works in the
interactive mode

>>> import ibm_db
>>> conn = ibm_db.connect( 'DATABASE', 'user', 'passwd')
>>> result = ibm_db.exec_immediate( conn, 'SELECT * FROM TEST FETCH FIRST 1 
>>> ROWS ONLY')
>>> row = ibm_db.fetch_tuple( result )
>>> for r in row:
...print r
...
13
ABC
4
2009-05-11

The same executed from a script using python testdb.py does not yield
anything , What am I doing wrong ?

import ibm_db
conn = ibm_db.connect( 'DATABASE', 'user', 'pwd')
result = ibm_db.exec_immediate( conn, 'SELECT * FROM TEST FETCH FIRST
1 ROWS ONLY')
row = ibm_db.fetch_tuple( result )
for r in row:
  print r

==
>python testdb.py
database value after unicode conversion is : N
database value sent to CLI is : N
>
==
-- 
http://mail.python.org/mailman/listinfo/python-list