Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Facing issue with skipRows] #317

Closed
1 task
shrineeraj opened this issue Jan 13, 2020 · 5 comments
Closed
1 task

[Facing issue with skipRows] #317

shrineeraj opened this issue Jan 13, 2020 · 5 comments
Assignees

Comments

@shrineeraj
Copy link

shrineeraj commented Jan 13, 2020

Describe the bug
Issue in skipRows with header=true strictColumnHandling: true,maxRows:some_number

Parsing or Formatting?

  • Formatting
  • [Parsing ] Parsing

To Reproduce
Steps to reproduce the behavior:

const csv = require('@fast-csv/parse');
	const rows = [
    'header1,header2\n',
    'col1\n',
    'col2,col2\n',
    'col3\n',
    'col4,col4\n',
    'col5,col5\n',
    'col6,col6\n',
];
const stream = csv
		.parse({ headers: true, skipRows: 2 ,strictColumnHandling: true,maxRows:4
		})
		.on('error', error => console.error(error))
		.on('data-invalid', (row, rowNumber) => {
			console.log(`Invalid [rowNumber=${rowNumber}] [row=${JSON.stringify(row)}]`);
		})
		 .on('data', row => console.log(`valid ${JSON.stringify(row)}`))
		.on('end', rowCount => console.log(`Parsed ${rowCount} rows`));
	rows.forEach(row => stream.write(row));
	stream.end();

Expected behavior
i am accepting the output like this
Invalid [rowNumber=1] [row=["col3"]]
valid {"header1":"col4","header2":"col4"}
valid {"header1":"col5","header2":"col5"}
valid {"header1":"col6","header2":"col6"}
Parsed 4 rows

but actual output given is
Invalid [rowNumber=1] [row=["col1"]]
Invalid [rowNumber=2] [row=["col3"]]
valid {"header1":"col4","header2":"col4"}
valid {"header1":"col5","header2":"col5"}
Parsed 4 rows

Desktop (please complete the following information):

  • OS: [WINDOW 10]
  • OS Version [e.g. Mojave]
  • Node Version [9.3.0]

Additional context
i am executing your code of skip_rows.examples.js with some modifications strictColumnHandling: true and maxRows:some_number. i am doing wrong or it's there an issue

@shrineeraj shrineeraj added the bug label Jan 13, 2020
doug-martin added a commit that referenced this issue Feb 14, 2020
* [FIXED] Issue where invalid rows were not accounted for when skipRows was set #317
doug-martin added a commit that referenced this issue Feb 14, 2020
@doug-martin
Copy link
Contributor

Thank you for the great example to reproduce!

This fix will be in v4.0.3

@doug-martin doug-martin mentioned this issue Feb 14, 2020
@doug-martin
Copy link
Contributor

published!

@shrineeraj
Copy link
Author

shrineeraj commented Feb 14, 2020 via email

@shrineeraj
Copy link
Author

sorry to say but i am getting the same out put as given previously. i am just using your skip_rows.example.js (fast-csv/examples/parsing-js/examples) file with some modification but not getting the desired out
i am accepting the output like this
Invalid [rowNumber=1] [row=["col3"]]
valid {"header1":"col4","header2":"col4"}
valid {"header1":"col5","header2":"col5"}
valid {"header1":"col6","header2":"col6"

image

@shrineeraj
Copy link
Author

shrineeraj commented Feb 14, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants