471,338 Members | 1,044 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 software developers and data experts.

open file and create file .

I am learning to python programming and i have some questions about python code .
i have tried to write some codes for reading a file from a different database and creating a file if the file doesn,t exsit on database. I have to look 3 databases before I create the file. Can anyone help me how to solve this problem ? I need a datastruktur to look up the file fro 3 different databases.what can i do?help.


For example.

I think I have to use this
dbm= open('dbm.fil','r'):
for line in dbms.xreadlines():
Nov 26 '07 #1
1 1616
Try with:
Expand|Select|Wrap|Line Numbers
  1. tofind="some"
  2. f=open ("your_db.db","r)
  3. f=f.read().split('\n')  #change \n with your divisor...
  4. found=False
  5. for i in f:
  6.     if i==tofind:
  7.          found=i
  8.          break
  9. if not found:
  10.         ##no entry has been found, write your code here
  11. else:
  12.         ##found an entry, write your code here
  13.  
Nov 26 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Eino Mäkitalo | last post: by
6 posts views Thread by Alex | last post: by
8 posts views Thread by Kenneth P | last post: by
4 posts views Thread by g4356 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.