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

ignoreColumns is not working #455

Open
onsightit opened this issue Oct 27, 2022 · 1 comment
Open

ignoreColumns is not working #455

onsightit opened this issue Oct 27, 2022 · 1 comment

Comments

@onsightit
Copy link

I occasionally get CSVs that have an extra comma on the header and rows. This results in the parser giving me unwanted columns, like 'field18'. I tried using the ignoreColumns option parameter like this:

		const converter = csv({
			noheader: false,
			ignoreColumns: /field\d+$/
		})

Or even hardcoding the column like this:

		const converter = csv({
			noheader: false,
			ignoreColumns: /field18/
		})

But it still gives me these unwanted columns. I suspect it is because 'field18' is not in the header. How can I get around this without deleting the trailing commas? I have an automated process, so manually editing the CSV is not an option.

Thanks!

@Kyaw-Zin-Thant
Copy link

I found the option to skip empty data columns, you can use ignoreEmpty.

const converter = csv({ noheader: false, ignoreEmpty: true })

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

No branches or pull requests

2 participants