vidyashankara Posted June 15, 2006 Share Posted June 15, 2006 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 112345123456789067890ENDModel 223456234561789017890END[/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]12345123456789067890END[/code]How do i go this?Can i do it using linux system commands? Quote Link to comment https://forums.phpfreaks.com/topic/12099-php-text-operations/ Share on other sites More sharing options...
litebearer Posted June 15, 2006 Share Posted June 15, 2006 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 writeLite.... Quote Link to comment https://forums.phpfreaks.com/topic/12099-php-text-operations/#findComment-46085 Share on other sites More sharing options...
vidyashankara Posted June 15, 2006 Author Share Posted June 15, 2006 [!--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 writeLite....[/quote]Each group of data is seperated by MODEL Number and ENDLike[code]Model 1123412341234 ENDModel 2asdfasdfasdfENDModel 3uyiopityutryopitrytryopiyp END[/code]I cant seem to find to any code to extract just model 1,2 or 3. Quote Link to comment https://forums.phpfreaks.com/topic/12099-php-text-operations/#findComment-46089 Share on other sites More sharing options...
litebearer Posted June 16, 2006 Share Posted June 16, 2006 Look into...strpos() and substr()You can accomplish what you want with the help of those.Lite... Quote Link to comment https://forums.phpfreaks.com/topic/12099-php-text-operations/#findComment-46143 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.