LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Free open source CSV format parsing software written in C/C++ (https://www.linuxquestions.org/questions/programming-9/free-open-source-csv-format-parsing-software-written-in-c-c-883886/)

Aquarius_Girl 06-02-2011 06:10 AM

Quote:

Originally Posted by SigTerm (Post 4373993)
Sounds like you forgot to handle quotes. That's the only "difficulty", but it is still fairly trivial to implement.

The non-human readable format of that file doesn't have quotes. :D It is simply like:
Code:

1,34.7607233,-117.0107599,90,10
2,32.7607232,-112.0107592,92,12

You asked me what's the problem..so here is the problem: What is the function equivalent to fseek in ifstream?

EDIT
Well, I have found the solution to my problem (without fseek) but still I would like to know about the above question.

SigTerm 06-02-2011 08:22 AM

Quote:

Originally Posted by Anisha Kaul (Post 4373996)
What is the function equivalent to fseek in ifstream?

seekg.
I'd recommend to check cplusplusreference or msdn when question like this appears.

MTK358 06-02-2011 08:53 AM

Quote:

Originally Posted by Anisha Kaul (Post 4373996)
You asked me what's the problem..so here is the problem: What is the function equivalent to fseek in ifstream?

The first result from searching "ifstream" on Google:

http://www.cplusplus.com/reference/iostream/ifstream/

Aquarius_Girl 06-02-2011 09:41 AM

Quote:

Originally Posted by SigTerm (Post 4374076)
seekg.
I'd recommend to check cplusplusreference or msdn when question like this appears.

and you really thought, I hadn't checked on seekg and cplusplusreference before asking here? :rhetorical question:

I couldn't understand properly how to use seekg's parameters actually, just now someone called "Martin" seems to explain them in the last post here, in my thread: http://stackoverflow.com/questions/6...without-gettin

It happens to me sometimes,
now when I read the same doc, they seem to be pretty much clear :rolleyes:

SigTerm 06-02-2011 09:51 AM

Quote:

Originally Posted by Anisha Kaul (Post 4374136)
and you really thought, I hadn't checked on seekg and cplusplusreference before asking here? :rhetorical question:

Well, you didn't say "I already checked cplusplusreference/msdn and didn't find an answer"...

catkin 06-02-2011 10:03 AM

Quote:

Originally Posted by Anisha Kaul (Post 4373804)
This one: http://www.robosuv.com/html/rddf_2004.html
[snip]
By "line ends" you mean some special characters denoting the end of line? Well that file doesn't have anything other than a '\n' char at the end.

and I am not sure that I have understood what you meant by "deriving an algorithm for C++ from awk". Did you mean that you'll be writing the code for the same in awk and then I'll translate the awk code to C++?
Anyway, I am an awk/sed/bash/perl illiterate. So won't be able to "read" anything you post in awk.

If you do bother to post the awk code [and also do write "what" each line is doing in plain English], it might be helpful in present/future, to either me or to someone else.

That looks like a nicely simple subset of CSV file features,

I meant actual line ends inside the data like
Code:

"foo","b
ar","oof","rab"

awk (at least the way I use it to do this sort of thing) is very like C given that $0 is "the last line read from the file" and $1, $2 ... are the result of passing it through a strtok function. The awk script is already on LQ in this thread but you don't need anything as complex as that. Translation available on request.

Aquarius_Girl 06-02-2011 10:03 AM

Quote:

Originally Posted by SigTerm (Post 4374147)
Well, you didn't say "I already checked cplusplusreference/msdn and didn't find an answer"...

That's because, well at least I, before commenting/answering someone, do check up the person's posting history (and unfortunately assume that other people also do the same)! and secondly most of the regulars here know each other's posting history so...I didn't feel the need to mention it :eek:

Anyway, will take care next time!

P.S: Had this been in a new thread, definitely I would have mentioned all those searches.

XavierP 06-03-2011 01:40 PM

Moved to Programming.

MTK358 06-03-2011 02:11 PM

Quote:

Originally Posted by Anisha Kaul (Post 4374166)
That's because, well at least I, before commenting/answering someone, do check up the person's posting history (and unfortunately assume that other people also do the same)! and secondly most of the regulars here know each other's posting history so...I didn't feel the need to mention it :eek:

Whether I know a members usual habits or not, I expect that what they say they did is what they did, nothing more, nothing less.

Aquarius_Girl 06-08-2011 11:39 PM

Quote:

Originally Posted by catkin (Post 4374164)
I meant actual line ends inside the data like
Code:

"foo","b
ar","oof","rab"

awk (at least the way I use it to do this sort of thing) is very like C given that $0 is "the last line read from the file" and $1, $2 ... are the result of passing it through a strtok function.

Thanks for the link, the code doesn't look too scary indeed, it looks like C <relief>!
Though I don't need it right now, but it will be helpful in future perhaps. I am thinking of writing a C translation for that in my blog sometime.


All times are GMT -5. The time now is 04:45 AM.