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

skipFirstNLines should not take the first line as header #1045

Closed
jkruke opened this issue Mar 7, 2024 · 0 comments
Closed

skipFirstNLines should not take the first line as header #1045

jkruke opened this issue Mar 7, 2024 · 0 comments

Comments

@jkruke
Copy link
Contributor

jkruke commented Mar 7, 2024

I think this feature hasn't been implemented as wanted in the referenced issue #738 !
The example CSV was:

This is a data file generated by some old software.
Next line will contain a headers of parameters.
Temperature, Humidity, Voltage
22.5, 45.5, 220
23.0, 44.0, 219

Expected output should be (to be fair, it wasn't precisely specified):

Temperature, Humidity, Voltage
22.5, 45.5, 220
23.0, 44.0, 219

But the actual output with skipFirstNLines=2 is (according to the test cases):

This is a data file generated by some old software.
23.0

Analogue to the following test case in the code:
https://github.com/mholt/PapaParse/pull/1021/files#diff-e0ce8cb4901057c1880bee545909a64f38c7383b4d41982d6f2db9a8ec81eac7R1588

{
		description: "Skip First N number of lines , with header and 3 rows",
		input: 'a,b,c,d\n1,2,3,4\n4,5,6,7',
		config: { header: true, skipFirstNLines: 1 },
		expected: {
			data: [{a: '4', b: '5', c: '6', d: '7'}],
			errors: []
		}
	}

This test case is not realistic because it does not reflect a CSV with some preamble lines to be skipped.
should be rather: input: 'to-be-ignored\na,b,c,d\n1,2,3,4', and expected.data: [{a: '1', b: '2', c: '3', d: '4'}].

If someone wanted to skip rows of the record set, it should not be done during the parsing phase, but later when working with the data sets by doing some simple postprocessing such as data = data.slice(1).

@bhuvaneshwararaja, @pokoli could you please take a look at it and give me some feedback about my thoughts? :)

Originally posted by @jkruke in #1021 (comment)

jkruke pushed a commit to jkruke/PapaParse that referenced this issue Mar 7, 2024
jkruke added a commit to jkruke/PapaParse that referenced this issue Mar 7, 2024
jkruke added a commit to jkruke/PapaParse that referenced this issue Mar 7, 2024
mholt pushed a commit that referenced this issue Aug 5, 2024
…ine as header (#1045) (#1046)

* Only skip first n lines in the first chunk and don't take the first line as header (#1045)

* use newline from config (or guess if unset)

---------

Co-authored-by: Jonas Krukenberg <jonas.krukenberg@haw-hamburg.de>
@mholt mholt closed this as completed Aug 5, 2024
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