You Are Here:

Community: Developer Discussion Boards

#1 Old How to read a txt file contents to a form - 2009-03-09, 13:45

Join Date: Feb 2009
Posts: 72
v divya
Offline
Regular Contributor
Hi again,

I want to know how to read the contents of a txt file.. My txt file contains three values seperated by commas.. I wanted to fetch them one at a time and display them in a form of three text boxes..

How to get this done?
Reply With Quote

#2 Old Smile Re: How to read a txt file contents to a form - 2009-03-09, 13:53

Join Date: May 2007
Posts: 2,737
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Quote:
Originally Posted by v divya View Post
Hi again,

I want to know how to read the contents of a txt file.. My txt file contains three values seperated by commas.. I wanted to fetch them one at a time and display them in a form of three text boxes..

How to get this done?
Hi Divya,

Most of the questions you ask are answered here.

In this case, here.
Reply With Quote

#3 Old Re: How to read a txt file contents to a form - 2009-03-09, 14:07

Join Date: Dec 2007
Posts: 409
Location: Tempe, AZ
Send a message via Yahoo to shubhendra Send a message via Skype™ to shubhendra
shubhendra's Avatar
shubhendra
Offline
Forum Nokia Champion
A bit of file handling and a bit of String handling (Search for split() in python) would do the job.


IDEAS is all they need but still they think only Genius can give them that.
Reply With Quote

#4 Old Re: How to read a txt file contents to a form - 2009-03-09, 15:03

Join Date: Sep 2007
Posts: 395
Location: Bhavnagar
Send a message via Yahoo to james1980
james1980's Avatar
james1980
Offline
Forum Nokia Champion
Hi,
if you want to split your string separated by comma than try this code
Code:
y='hi,how,r,u'
print string.split(y,',')
hope this helps you.


Jajal Mehul
Reply With Quote

#5 Old Re: How to read a txt file contents to a form - 2009-03-09, 15:05

Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Offline
Forum Nokia Champion
Quote:
Originally Posted by james1980 View Post
Hi,
if you want to split your string separated by comma than try this code
Code:
y='hi,how,r,u'
print string.split(y,',')
hope this helps you.
Remember that you need to import the string module to use that code. But it's much easier to do it directly:
Code:
y='hi,how,r,u'
print y.split(',')
Reply With Quote

#6 Old Re: How to read a txt file contents to a form - 2009-03-09, 15:33

Join Date: Sep 2007
Posts: 395
Location: Bhavnagar
Send a message via Yahoo to james1980
james1980's Avatar
james1980
Offline
Forum Nokia Champion
Quote:
Originally Posted by bogdan.galiceanu View Post
Remember that you need to import the string module to use that code. But it's much easier to do it directly:
Code:
y='hi,how,r,u'
print y.split(',')
Oh thanks bogdan.
Its much easy than what i had suggested.


Jajal Mehul
Reply With Quote

#7 Old Re: How to read a txt file contents to a form - 2009-03-09, 18:49

Join Date: Jun 2008
Posts: 45
maclun123
Offline
Registered User
You may find 'pickle' module useful here.
It helps you store and retrieve different structures in a text file. No need for any manual conversion or string analysis.

simple use - SAVE:
Code:
import pickle
f = open(file, 'w')
pickle.dump(variable, f)
f.close()
simple use - LOAD:
Code:
f = open(file, 'r')
variable = zpickle.load(f)
f.close()
mac
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Read contents of SMS file carlyle General Messaging 4 2008-08-15 19:14
[announce] PyUIQ. Python for UIQ 2.1 and 3.x OscarBernabeu Python 35 2008-01-17 10:12
Read and Write the encrypted data form file ankushbabrekar General Symbian C++ 6 2007-04-18 11:53
please please help me show contents of file txt finalcomp General Symbian C++ 1 2006-07-17 13:36
socket read hangs until socket is closed camroe Mobile Java Networking & Messaging & Security 1 2005-07-21 10:44

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia