473,395 Members | 1,949 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,395 software developers and data experts.

parsing formatted data

hi everyone,
it would be great if someone could help me with this code. I have to parse the following data stored in a text file.
30 30
9 2.5 0.8654
I N (5,9) (5,52) (13,52) (13,9)
C N (16,9) (16,21) (24,21) (24,9)

would i need to tokenize the data first?? . I am coding in C and I parsed the first two lines, storing them in local variables using something like:

Expand|Select|Wrap|Line Numbers
  1. FILE *nlfp;
  2. if( (nlfp=fopen(argv[1], "r"))==NULL) {
  3.         fprintf(stderr, "cannot open %s\n", argv[1]);
  4.         exit(-1);
  5.     }
  6. fscanf(nlfp, "%d %d %d %f %f %f %f",  &gridX,
  7.         &gridY, &gaussFilterSize, &sigma, &normF, &sigA, &sigR);
  8.  
but i am not to sure, how to read the remaining portion.
Thanks a lot..
Nov 19 '06 #1
1 1361
horace1
1,510 Expert 1GB
it depends what the lines represent?
I N (5,9) (5,52) (13,52) (13,9)
C N (16,9) (16,21) (24,21) (24,9)
is each line a string of characters or are the number pairs simple integers or complex numbers, e.g. (5,9) could 5 + j9? What is this information suposed to be?

also the lines
30 30
9 2.5 0.8654
contans 5 numbers whereas your scanf
fscanf(nlfp, "%d %d %d %f %f %f %f", &gridX,
&gridY, &gaussFilterSize, &sigma, &normF, &sigA, &sigR);
attempts to read 7 numbers (3 integer and 4 float)
Nov 19 '06 #2

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

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
6
by: Tuang | last post by:
I've been looking all over in the docs, but I can't figure out how you're *supposed* to parse formatted strings into numbers (and other data types, for that matter) in Python. In C#, you can say...
1
by: Mike Labman | last post by:
I'm parsing an XML document using the XMLDOM object in ASP. I am running into a problem with a section formatted like this: <MasterElement> TitleOfElement <Abbreviation> TOE </Abbreviation>...
0
by: Fabian Kr?ger | last post by:
Hello, I got a weird problem and need your help and ideas... I´ve written an php application which imports data in XML format and writes this data to a MySQL database to have a faster access....
12
by: BGP | last post by:
I am working on a WIN32 API app using devc++4992 that will accept Dow Jones/NASDAQ/etc. stock prices as input, parse them, and do things with it. The user can just cut and paste back prices into a...
9
by: Mantorok Redgormor | last post by:
If I am parsing a config file that uses '#' for comments and the config file itself is 1640 bytes, and the format is VARIABLE=VALUE, is it recommended to use a) fgetc (parse a character at a...
29
by: zoltan | last post by:
Hi, The scenario is like this : struct ns_rr { const u_char* rdata; }; The rdata field contains some fields such as :
6
by: bfowlkes | last post by:
Hello, I am trying to parse two pre-formatted text files and write them to a different files formatted in a different way. The story about this is I was hired along with about 20 other people...
3
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in...
3
by: Kailash Nadh | last post by:
Hello all. I have this tab formatted hierarchical structure. -------------------- 0 A 1 B 2 C 2 D 1 E --------------------
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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...
0
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,...
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,...

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.