Welcome to the Community Website Support Forum - by UltraWebsiteHosting.
Header

Community Website Support Forum - by UltraWebsiteHosting » Externally Imported Information » PHP and MySQL » How to read fields from a file?

Reply
Thread Tools vBmenu Seperating Image Display Modes
How to read fields from a file?
Old 10-01-2008, 10:02 AM   #1
Kurda Yon
 
Status: Guest
Posts: n/a
Default How to read fields from a file?

Hi,

I have a file with data written in a "matrix" form. In other words,
every row contains a fixed number of fields and I am interested in the
value of each field of every row.

I managed to read rows in the following way:
f = open('filename.dat','r')
for line in f:
x = line
f.close()

However, I cannot find out how to split every line into fields? What
should I do if I, let's say, need a value which is located in the
third row in the second column (field).

Thank you!
  Reply With Quote
Old 10-01-2008, 10:02 AM   #2
Kurda Yon
 
Status: Guest
Posts: n/a
Default Re: How to read fields from a file?

I found line.split()! It works great! I think it is exactly what I
need. Or may be there are some more elegant solutions?
  Reply With Quote
Old 10-01-2008, 10:02 AM   #3
Kurda Yon
 
Status: Guest
Posts: n/a
Default Re: How to read fields from a file?

On Oct 1, 5:07 am, Kristaps Kûlis <Kristaps.Ku...@gmail.com> wrote:
> On Oct 1, 2:58 am, Kurda Yon <kurda...@yahoo.com> wrote:
>
> > I found line.split()! It works great! I think it is exactly what I
> > need. Or may be there are some more elegant solutions

>
> Why are you posting in comp.lang.php questions about language with is
> not connected to PHP ?
>
> LOL


Sorry, I did it by a mistake. It should be python... Thank you that
you indicated that.
  Reply With Quote
Old 08-31-2009, 03:17 AM   #4
intelligence économique
 
Status: Junior Member
Join Date: Aug 2009
Posts: 1
Default intelligence économique

Bonjour,
si vous etes à la recherche de ressources relatifs à l'intelligence économique, à la veille ou au knowledge managment,
vous trouverez votre bonheur sur le site du professeur luc quoniam, professeur en intelligence économique
A bientot
intelligence économique is offline   Reply With Quote
Old 08-31-2009, 09:46 PM   #5
carlobee
 
Status: Senior Member
Join Date: Jul 2009
Posts: 141
Default

if you wish to be understood , then you can speak english.

carlobee is offline   Reply With Quote
Old 03-15-2010, 07:37 AM   #6
Relana
 
Status: Junior Member
Join Date: Mar 2010
Posts: 17
Default

Tutorials are forever in these problems!!!))
Relana is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: FAQ 5.28 How can I read in an entire file all at once? Peter J. Holzer CGI 0 10-27-2008 04:04 PM
AspectJ: solution to Java's repetitiveness? jhc0033@gmail.com JSP and Java 93 08-21-2008 07:23 AM
Perl read file eat up my memory... howa CGI 5 08-21-2008 07:11 AM
Re: Read data from Access MDB file? Richard PHP and MySQL 0 08-20-2008 11:20 PM
Re: Read data from Access MDB file? Richard PHP and MySQL 0 08-20-2008 11:20 PM


All times are GMT -8. The time now is 01:43 PM.