Hello!
I'd be very grateful if you can give some advice to me. I explain my
problem:
I want to read a file whose structure I need to be like this:
#comments...
value1,value2,v alue3,...,value N # comments...
#comments...
value1,value2,v alue3,...,value N # comments...
....
value1,value2,v alue3,...,value N # comments...
So what I want is to be able to read a file in which there are some
lists of values separated by new line. Each value is separated by a
comma. And there may be comments at the beggining or at the end of any line.
I can't use getline(...,... ,'\n') because I have to take care of '#'
I can't use getline(...,... ,'\#') because comments are not compulsory.
So what do you suggest?
thanks. 4 1491
|
| I can't use getline(...,... ,'\n') because I have to take care of '#'
| I can't use getline(...,... ,'\#') because comments are not compulsory.
|
Yes you can. Then check for the existance of "#". It it exists, remove it and everything that comes after that.
Nafai wrote: Hello!
I'd be very grateful if you can give some advice to me. I explain my problem:
I want to read a file whose structure I need to be like this:
#comments... value1,value2,v alue3,...,value N # comments... #comments... value1,value2,v alue3,...,value N # comments... ... value1,value2,v alue3,...,value N # comments...
So what I want is to be able to read a file in which there are some lists of values separated by new line. Each value is separated by a comma. And there may be comments at the beggining or at the end of any line.
I can't use getline(...,... ,'\n') because I have to take care of '#' I can't use getline(...,... ,'\#') because comments are not compulsory.
So what do you suggest?
thanks.
I would use an fstream and read a line at a time (so basically the
getline()). Then I would check the first character, if it's a # then the
line is a comment. If not, the the line contains values a possible comment.
How you handle when a line doesn't start with a # can be done 101 different
ways.
I asked this question because there are many files with this structure
and I thought there would be a "standard" way of doing sth like this. I
can do it my way but I would like to hear some tips or frequent ways of
doing this.
Thanks.
Alvin Beach escribió: Nafai wrote:
Hello!
I'd be very grateful if you can give some advice to me. I explain my problem:
I want to read a file whose structure I need to be like this:
#comments.. . value1,value2 ,value3,...,val ueN # comments... #comments.. . value1,value2 ,value3,...,val ueN # comments... ... value1,value2 ,value3,...,val ueN # comments...
So what I want is to be able to read a file in which there are some lists of values separated by new line. Each value is separated by a comma. And there may be comments at the beggining or at the end of any line.
I can't use getline(...,... ,'\n') because I have to take care of '#' I can't use getline(...,... ,'\#') because comments are not compulsory.
So what do you suggest?
thanks.
I would use an fstream and read a line at a time (so basically the getline()). Then I would check the first character, if it's a # then the line is a comment. If not, the the line contains values a possible comment. How you handle when a line doesn't start with a # can be done 101 different ways.
> I would use an fstream and read a line at a time (so basically the getline()). Then I would check the first character, if it's a # then the line is a comment. If not, the the line contains values a possible comment. How you handle when a line doesn't start with a # can be done 101 different ways.
I asked this question because there are many files with this structure
and I thought there would be a "standard" way of doing sth like this. I
can do it my way but I would like to hear some tips or frequent ways of
doing this.
Thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gert Van den Eynde |
last post by:
Hi all,
Could you give me some pointers on how to parse a text input file in C++?
Most will be config-file style input (keyword = data), but some maybe
'structures' like material{ name = n, position = x,y,z}.
Things that I have in my mind now are: 1) simply reading in strings,
analysing the strings myself, 2) writing a lexer/parser, 3)...
|
by: John Doe |
last post by:
I've been doing some reading/research on parsing simple configuration
files through C, and have heard various opinions on the matter. I'd like
to solicit some opinions and design criteria (as well as "gotchas") for
doing this.
I'm implementing a program that needs to read a standard configuration
file, in key=value pairs for starters...
|
by: Anthony Boudouvas |
last post by:
Hi to all,
i have a very simple XML file that i present to a user and i will allow
him/her
to manualy edit it and send it back to a listening server.
What is the best -simple- way to parse it so it does not contain anything
invalid after edit ??
I just need a simple data validation, no xml-schemas etc...
|
by: Christoph Bisping |
last post by:
Hello!
Maybe someone is able to give me a little hint on this:
I've written a vb.net app which is mainly an interpreter for specialized
CAD/CAM files.
These files mainly contain simple movement and drawing instructions like
"move to's" and "change color's" optionally followed by one or more numeric
(int or float) arguments. My problem is...
|
by: Jean-Marie Vaneskahian |
last post by:
Reading - Parsing Records From An LDAP LDIF File In .Net?
I am in need of a .Net class that will allow for the parsing of a LDAP
LDIF file. An LDIF file is the standard format for representing LDAP
objects. I need to be able to read the records from an LDIF file into
..Net.
There exists a Perl module that will do exactly this called...
| |
by: Rick Walsh |
last post by:
I have an HTML table in the following format:
<table>
<tr><td>Header 1</td><td>Header 2</td></tr>
<tr><td>1</td><td>2</td></tr>
<tr><td>3</td><td>4</td></tr>
<tr><td>5</td><td>6</td></tr>
</table>
With an XSLT styles sheet, I can use for-each to grab the values in
|
by: ankitdesai |
last post by:
I would like to parse a couple of tables within an individual player's
SHTML page. For example, I would like to get the "Actual Pitching
Statistics" and the "Translated Pitching Statistics" portions of Babe
Ruth page (http://www.baseballprospectus.com/dt/ruthba01.shtml) and
store that info in a CSV file.
Also, I would like to do this for...
|
by: Jacob Rael |
last post by:
Hello,
I have a simple script to parse a text file (a visual basic program)
and convert key parts to tcl. Since I am only working on specific
sections and I need it quick, I decided not to learn/try a full blown
parsing module. My simple script works well until it runs into
functions that straddle multiple lines. For example:
Call...
|
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 the file) with the location.
And for a particular section I parse only that section.
The file is something like,
.... DATAS
|
by: Chris Carlen |
last post by:
Hi:
Having completed enough serial driver code for a TMS320F2812
microcontroller to talk to a terminal, I am now trying different
approaches to command interpretation.
I have a very simple command set consisting of several single letter
commands which take no arguments. A few additional single letter
commands take arguments:
|
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...
| |
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. ...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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...
|
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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
| |
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...
|
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...
| |