Re: [Tutor] How o convert spaces into tabs??

2009-06-02 Thread शंतनू (Shantanoo)



jyotsna guleria wrote:

Hello every one,

I am trying to parse a file:

I want to convert all the spaces in between the characters to single tab.

e.g: my file has contents like:

1G579011  10  2   0  0
0   0   0   00
5Ht-2  60459  11  0   0  0
0   0   0   00



I want them to be separated by a single tab not with spaces..

It should look like:

1G5790111020000000
5Ht-2604591100000000

each separated by Tab...

It is a text file containing such a data ..


You can try re module.
More info at:
http://docs.python.org/library/re.html
http://www.regular-expressions.info/python.html

--
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] sqlite3 lists to database conversion/ using python variables in sqlite3

2008-11-19 Thread शंतनू (Shantanoo)
On Wed, Nov 19, 2008 at 4:48 PM, amit sethi [EMAIL PROTECTED]
wrote:
 Hi , i am trying to learn python and this is my first time with any
 databases . I am using sqlite3 to create a database of my music files and
 its
 metadata tags so here is what i wanted to do . Two list one of the
 attributes and one of their values ,how do i put it in the database.Here
is
 a simple code i think should work but isn't?
 import sqlite3
 conn=sqlite3.connect('/tmp/example2')
 c = conn.cursor()

 list1=['hello','hi']
 list2=['a','b']
c.execute('''create table ABC(hello text,hi text)''')
 list1_value= ,.join(list1)
 list2_value= ,.join(list2)
 c.execute('''insert into ABC (%s) values
 (%s)''')%(list1_value,list2_value)

You may try:
c.execute(insert into ABC(%s) values('%s') % (list1_value, list2_value))

regards,
shantanoo
-- 

Fred Allen  - An associate producer is the only guy in Hollywood who will
associate with a producer.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor