473,947 Members | 16,894 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unpacking a file which has tokens

1 New Member
Hi,

can someone please help.

I have a file which look something like this:

Group=01|[*1]
List=01|[*2]|20090801||3|
Item=01005000|[*3]|20091001|00000 0005000||
Item=01015000|[*4]|20091001|00000 0015000||
Item=01035000|[*5]|20091001|00000 0035000||
List=02|[*6]|20090801|||
Item=02003500|[*7]|20091001|00000 0003500||[*8]
Item=02001500|[*9]|20091001|00000 0001500|1|[*8]
Item=02006000|[*10]|20091001|00000 0006000||[*8]
List=03|[*11]|20090801|||
Item=03002900|[*12]|20090801|00000 0002900||
Item=03003500|[*13]|20090801|00000 0003500||[*14]
Item=03009500|[*15]|20091001|00000 0009500||[*14]
Item=03011000|[*16]|20091001|00000 0011000||[*14]

[*1]
ENG=Prepaid
[*2]
ENG=CellC
[*3]
ENG=CEL0050
[*4]
ENG=CEL0150
[*5]
ENG=CEL0350
[*6]
ENG=MTN
[*7]
ENG=MTN0035
[*8]
ENG=DIal *110 and follow instructions
[*9]
ENG=MTN0015
[*10]
ENG=MTN0060
[*11]
ENG=Vodacom
[*12]
ENG=VOD0029
[*13]
ENG=VOD0035
[*14]
ENG=Dial 100* and follow instructions
[*15]
ENG=VOD0095
[*16]
ENG=VOD0110

I need to process the file and build menu's for each level... I'm battling to unpack the file though. I've tried a combination of strstr and strtok_r but am not getting very far. Anyone do anything of the kind before??

Thanks
Oct 21 '09 #1
1 1528
donbock
2,426 Recognized Expert Top Contributor
Do you have flexibility in how you unpack the file? I find it much easier to parse and filter text files with perl than with C.

Another possibility: does the text file use a standard format? If so, then perhaps parsing tools are available for that standard.

I suggest you extract a manageable subset from the text file and parse it manually to build up the menus you seek. This will insure that you have a solid understanding of what needs to be done.
Oct 21 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
12250
by: Andy Mee | last post by:
Hello one and all, I'm developing an Asp.NET system to take a CSV file uploaded via the web, parse it, and insert the values into an SQL database. My sticking point comes when I try to split() the string returned by readline() on the file. The following code snippet works for me: tokens = "one,two,three,four".Split(",") for each token in tokens response.write("<td>"+token+"</td>")
2
4241
by: mahurshi | last post by:
I am trying to read a file full of numbers followed by spaces (and then do some cool stuff with it) My input file looks like this 1 0 1 0 1 0 1 1 1 0 0 1 1 0
7
1555
by: nephish | last post by:
Hey there, i have a text file with a bunch of values scattered throughout it. i am needing to pull out a value that is in parenthesis right after a certain word, like the first time the word 'foo' is found, retrieve the values in the next set of parenthesis (bar) and it would return 'bar' i think i can use re to do this, but is there some easier way? thanks
9
2781
by: Alex Buell | last post by:
I have a small text file which consist of the following data: ]] And the code I've written is as follows: ]] The trouble is, I can't work out why it goes into an infinite loop reading the information from the text file! Can anyone enlighten me as to what I am doing wrong?
6
3533
by: Richard | last post by:
Which way would you guys recommened to best parse a multiline file which contains two fields seperated by a tab. In this case its the linux/proc/filesystems file a sample of which I have included below: nodev usbfs ext3 nodev fuse vfat ntfs nodev binfmt_misc
2
1709
by: Fabian Braennstroem | last post by:
Hi, me again :-) I would like to parse a small batch file: file/read-case kepstop.cas file/read-data keps1500.dat solve/monitors/residual/plot no solve/monitors/residual/print yes
4
4640
by: McA | last post by:
Hi all, probably a dumb question, but I didn't find something elegant for my problem so far. In perl you can unpack the element of a list to variables similar as in python (a, b, c = ), but the number of variables need not to fit the number of list elements. That means, if you have less list elements variables are filled with
21
7303
by: Martin Geisler | last post by:
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkjlQNwACgkQ6nfwy35F3Tj8ywCgox+XdmeDTAKdN9Q8KZAvfNe4 0/4AmwZGClr8zmonPAFnFsAOtHn4JhfY =hTwE -----END PGP SIGNATURE-----
5
1544
by: Luis Zarrabeitia | last post by:
I need to parse a file, text file. The format is something like that: TYPE1 metadata data line 1 data line 2 .... data line N TYPE2 metadata data line 1 ....
0
10162
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9982
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11573
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11159
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10690
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9887
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6114
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4537
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3542
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.