473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Parse nightmare

I have a 1200 line text file with information that I need in the following
format.
FIGURE>SAMEFIGURE=NUMBER>SAMENUMBER=CHANNELNAME">S AMECHANNELNAME<DELETE

I want to break it down into this format.
$figure > $figure = $number > $number = $channel ">
$channel < the rest can be deleted
my way (not a lot of experience with this sort of problem..
don't laugh)

explode (">", $exFigure);
$figure = $exFigure[0];

explode ("=", $number);
$figure = $exFigure[1];
// then chop out after the >
And so on..
Would there be a better way I could learn...?

Thanks alot in advance

Mike.
Jul 17 '05 #1
3 2103
Hello Mike,

Try to use regular expressions.
For exmaple:
pref_match ( "/([^>]+)>([^=]+)=(\d+)>(\d+)=([^\"]+)\"/", $exFigure,
$matches );
$matches[1] = FIGURE
$matches[2] = SAMEFIGURE
$matches[3] = NUMBER
$matches[4] = SAMENUMBER
$matches[5] = CHANNELNAME

Excuse my bad pattern, im hurry :)

Dima
I have a 1200 line text file with information that I need in the following
format.
FIGURE>SAMEFIGURE=NUMBER>SAMENUMBER=CHANNELNAME">S AMECHANNELNAME<DELETE

I want to break it down into this format.
$figure > $figure = $number > $number = $channel ">
$channel < the rest can be deleted
my way (not a lot of experience with this sort of problem..
don't laugh)

explode (">", $exFigure);
$figure = $exFigure[0];

explode ("=", $number);
$figure = $exFigure[1];
// then chop out after the >
And so on..
Would there be a better way I could learn...?

Thanks alot in advance

Mike.

Jul 17 '05 #2
On Wed, 8 Oct 2003 16:45:59 -0700, "Michael Willcocks"
<mi*****@metrogroup.com.au> wrote:
I have a 1200 line text file with information that I need in the following
format.
FIGURE>SAMEFIGURE=NUMBER>SAMENUMBER=CHANNELNAME"> SAMECHANNELNAME<DELETE

I want to break it down into this format.
$figure > $figure = $number > $number = $channel ">
$channel < the rest can be deleted
my way (not a lot of experience with this sort of problem..
don't laugh)

explode (">", $exFigure);
$figure = $exFigure[0];

explode ("=", $number);
$figure = $exFigure[1];
// then chop out after the >
And so on..

Would there be a better way I could learn...?


Using explode here sounds quite reasonable; so long as the delimiter is never
part of the data, there's no real need to use anything more complicated.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #3
Thank you both for your input
Thanks alot seems to be working.
I have never used the pattern method because any time I have seen it in
use... It looks a little scary.

"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:2s********************************@4ax.com...
On Wed, 8 Oct 2003 16:45:59 -0700, "Michael Willcocks"
<mi*****@metrogroup.com.au> wrote:
I have a 1200 line text file with information that I need in the followingformat.
FIGURE>SAMEFIGURE=NUMBER>SAMENUMBER=CHANNELNAME"> SAMECHANNELNAME<DELETE

I want to break it down into this format.
$figure > $figure = $number > $number = $channel ">
$channel < the rest can be deleted
my way (not a lot of experience with this sort of problem..
don't laugh)

explode (">", $exFigure);
$figure = $exFigure[0];

explode ("=", $number);
$figure = $exFigure[1];
// then chop out after the >
And so on..

Would there be a better way I could learn...?
Using explode here sounds quite reasonable; so long as the delimiter is

never part of the data, there's no real need to use anything more complicated.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Drisco | last post by:
Hello, I realy need help,Searched the NG for a days with no vail. Sorry for the long script. I am trying to get a variable from php to flash. I have the following code in php <a...
21
by: William Stacey [MVP] | last post by:
Anyone know of some library that will parse files like following: options { directory "/etc"; allow-query { any; }; // This is the default recursion no; listen-on { 192.168.0.225;...
0
by: Deena | last post by:
Hi Windows forms layout is turning to be a nightmare. I add my controls to a form and then save it and then it just get's all messed up. I'm using inheritance if this makes any difference. Also...
4
by: Dave | last post by:
Hello All, I am having a nightmare trying to add a new row to my Datagrid. When I use the code below I get the error: 'Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount. Can...
14
by: Roland Hall | last post by:
Since I'm not getting any response from the community, I'm reposting this under my managed account. I've turned my web.config friendly error messages off and it may be easier to view what I'm...
6
by: Jim Mirra | last post by:
Hey, I have been working on this for a while now and I keep getting the same error. here is my code: ------- start code --------- Dim strSQL = "Select tagid,itemid,description,status,...
2
by: Afshar | last post by:
Dear nice people around the world! Please help ending this nightmare, I have 2 problem with ASP.NET Menu control First: I have a horizontal menu at top of my page, each item have some sub-items...
3
by: Samuel Shulman | last post by:
I get the following error Error 2 Could not load file or assembly 'RusticiSoftware.ScormContentPlayer.Logic, Version=2006.1.2576.40320, Culture=neutral,...
9
by: Bo Yang | last post by:
Hi, guys. I am now developing an application in which I need to fetch some html page, and then parsing it to get some intended content in it. Because HTML is not a standard XML format, so I am...
10
by: Andrew Wan | last post by:
I have been having a nightmare with ASP/ASP.NET & IIS6. We use Msxml2.DOMDocument.4.0 object to create a XML object in ASP. The Msxml2.DOMDocument.4.0 is from the Windows Platform SDK Feb 2003...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.