Jump to content

Archived

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

vidyashankara

PHP Text Operations

Recommended Posts

Lets say i have a text file

[code]

HEADER    LIPID TRANSPORT                         23-SEP-97   1AV1              
TITLE     CRYSTAL STRUCTURE OF HUMAN APOLIPOPROTEIN A-I                        
COMPND    MOL_ID: 1;          
Model           1
12345
12345
67890
67890
END
Model           2
23456
23456
17890
17890
END
[/code]

Question one: how do i read the lines begining with TITLE? I need a script to ouput what comes after TITLE, In this case, I need the script to output CRYSTAL STRUCTURE OF HUMAN APOLIPOPROTEIN A-I

Question two: How do i read the data between 2 lines? Lets say, if i want to read the data between Model 1 and Model 2, the script should output
[code]
12345
12345
67890
67890
END
[/code]

How do i go this?
Can i do it using linux system commands?

Share this post


Link to post
Share on other sites
Hmmm...

Kind of like asking how do I fix an engine.. are the bolts metric or US, are they left hand thread or right etc etc.

In other words, start with the structure of the file...

does each line end with the same 'character', such that said 'character' is ONLY used to end lines.

does each line represent a unqiue piece or group of information? and if it is a 'group' how are the pieces DISTINCTIVELY separated?

Will the file and subsequent versions of it follow the same format?

Those kinds of questions and answers about the file will narrow down the method of using the information in the file simply and effectively.

do a google search on php file handling read write

Lite....

Share this post


Link to post
Share on other sites
[!--quoteo(post=384370:date=Jun 15 2006, 04:15 PM:name=litebearer)--][div class=\'quotetop\']QUOTE(litebearer @ Jun 15 2006, 04:15 PM) [snapback]384370[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hmmm...

Kind of like asking how do I fix an engine.. are the bolts metric or US, are they left hand thread or right etc etc.

In other words, start with the structure of the file...

does each line end with the same 'character', such that said 'character' is ONLY used to end lines.

does each line represent a unqiue piece or group of information? and if it is a 'group' how are the pieces DISTINCTIVELY separated?

Will the file and subsequent versions of it follow the same format?

Those kinds of questions and answers about the file will narrow down the method of using the information in the file simply and effectively.

do a google search on php file handling read write

Lite....
[/quote]

Each group of data is seperated by MODEL Number and END

Like

[code]
Model 1
1234
1234
1234
END
Model 2
asdf
asdf
asdf
END
Model 3
uyiopityu
tryopitry
tryopiyp
END
[/code]

I cant seem to find to any code to extract just model 1,2 or 3.

Share this post


Link to post
Share on other sites
Look into...

strpos()

and

substr()

You can accomplish what you want with the help of those.

Lite...

Share this post


Link to post
Share on other sites

×

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.