Importing database: newbie issue

Pieter Claerhout Pieter.Claerhout at Creo.com
Thu Jan 22 05:52:15 EST 2004


I would read in the file line by line and then extract the parts I need,
provided the database file is a text file. A small example:

### CODE SAMPLE
f = open( 'MyDatabaseFile', 'r' )
data = f.readlines()
f.close()

for record in data:
	field1 = record[32:32+12]
	field2 = record[50:50+8]
### END

Hope this answers your question.

cheers,


pieter

Creo
pieter claerhout | product support prinergy | tel: +32 2 352 2511 |
pieter.claerhout at creo.com | www.creo.com

IMAGINE CREATE BELIEVE(tm)


-----Original Message-----
From: Angelo Secchi [mailto:secchi at sssup.it] 
Sent: 22 January 2004 11:55
To: python-list at python.org
Subject: Importing database: newbie issue


Hi,
I have a database with a fixed format structure (i.e. i know the
starting point and the length of each of the field composing the
database) and I would like to extract from it only few fields (ex the
one starting from the 32nd position with length 12...).
What is the best way to do that?

Thank
a

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




More information about the Python-list mailing list