Giter Site home page Giter Site logo

Comments (11)

ben-strasser avatar ben-strasser commented on July 2, 2024

from fast-cpp-csv-parser.

kirnhans avatar kirnhans commented on July 2, 2024

So I tried to use your parser but it either threw a missing column or extra column error, though I was using it correctly. When I changed the type of and used, it was able to run, but did not actually parse the row properly when I called read_row - it did not overwrite the variables I passed into the function. I'm not sure how to use this library at all.

from fast-cpp-csv-parser.

ben-strasser avatar ben-strasser commented on July 2, 2024

from fast-cpp-csv-parser.

kirnhans avatar kirnhans commented on July 2, 2024

https://raw.githubusercontent.com/kirnhans/15418-project/master/data/cancer/cancer_test.csv
is our dataset.

https://github.com/kirnhans/15418-project/blob/master/ParallelRandomForest.cpp#L11
is our code for using your parser.

Right now next_line will return the correct ASCII values, so long as the parser uses logical ands, but read_row does not work.

from fast-cpp-csv-parser.

ben-strasser avatar ben-strasser commented on July 2, 2024

Hi,

I cannot reproduce the problem. Consider this code:

#include "csv.h"
#include <iostream>
using namespace std;

int main(){
	io::CSVReader<1> in("cancer_test.csv");
	in.read_header(io::ignore_extra_column, "y");
	int y;
	cout << "y" << endl;
	while(in.read_row(y)){
		cout << y << endl;
	}
	return 0;
}

and the following shell code:

g++ main.cpp -std=c++11 -pthread -o foo
./foo > test.out
sed -E "s/^.*(.)$/\1/" < cancer_test.csv > sed.out
diff test.out sed.out

The diff has no output, i.e., the files are equal, i.e., the last column is correctly selected. The error seems to be in your code.

Best Regards
Ben Strasser

from fast-cpp-csv-parser.

kirnhans avatar kirnhans commented on July 2, 2024

Does the code still work when you use "in.set_file_line(index)"?

from fast-cpp-csv-parser.

kirnhans avatar kirnhans commented on July 2, 2024

Sorry about that - it turns out that one of the files wasn't correctly formatted.
When I use set_file_line and then read_row, it doesn't read the line which I used as the argument, but the line it was at previously. This is a problem because I want random accesses.

from fast-cpp-csv-parser.

ben-strasser avatar ben-strasser commented on July 2, 2024

from fast-cpp-csv-parser.

paulharris avatar paulharris commented on July 2, 2024

from fast-cpp-csv-parser.

ben-strasser avatar ben-strasser commented on July 2, 2024

from fast-cpp-csv-parser.

paulharris avatar paulharris commented on July 2, 2024

(edited to change "standard" to "RFC" as its just an RFC not an actual standard)

Sorry for the late reply,

The RFC for CSV specifies unescaped line breaks, they just need to be within quotes.
https://www.ietf.org/rfc/rfc4180.txt
See number 6

  1. Fields containing line breaks (CRLF), double quotes, and commas
    should be enclosed in double-quotes. For example:

    "aaa","b CRLF
    bb","ccc" CRLF
    zzz,yyy,xxx

Everyone has a different opinion of what a CSV format should be.
It would be nice if everyone just followed one format...

My branch of this project supports the RFC correctly (to my knowledge):
https://github.com/paulharris/cppcsv
It uses a state machine to parse the format, seems pretty quick.
Not sure if its as fast as your library though, I haven't had a chance to compare.

Best regards,
Paul

from fast-cpp-csv-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.