Jump to content

Newbie Alert - Parsing Pipe Delimited Text File


adredd

Recommended Posts

Hi All,

 

Not even sure if I need to do this with php, but I'm thinking perhaps so...

 

I've got a pipe delimited text file that looks something like this:

 

TX55|M/SUNNY|72|68|73|21|S|9|N/A|10|02|

TX56|P/CLOUDY|79|76|79|48|S|13|N/A|10|03|

TX57|SUNNY|73|69|73|28|SSE|13|29.83|10|01|

TX58|SUNNY|77|77|77|38|SE|12|29.72|10|01|

 

There's about 100 lines to it. What I need to do is pull out the line that begins with "TX58" and put it into some sort of useable format (this is all weather information) to put on a website dynamically. This info gets uploaded to us 6 times a day or somesuch.

 

Is this something that's doable with php, and if so, how (or rather, where/what do I Google for)? I just don't know enough about php to even know where to begin looking.

 

Many thanks in advance!

the following links should get you what you need...

 

http://us2.php.net/manual/en/function.fopen.php    - open a file to read

http://us2.php.net/manual/en/function.fgets.php    - read the file ( line by line )

http://us2.php.net/manual/en/function.substr.php  - pull the first few characters and see if they == TX58

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.