-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Skip lines future (Feature Suggestion) #738 #1021
Conversation
What you are proposing is already implemented using the |
Hi @pokoli , But this PR will add a config to skip the N number of rows in the beginning of the csv. Please check it once again , it is relevant to the issue #738 as well. |
Ok, then we need to document this new flag to explain which is the ussage. I think the flag will be better named as Could you have a look at the test suite? it seems you introduced some failing tests. |
Hi @pokoli , Thanks |
6c63dec
to
b133cfb
Compare
Hi @pokoli , I have updated the PR |
b133cfb
to
28dd2de
Compare
28dd2de
to
9ee3a20
Compare
Just a small note: This does not work for quoted fields...
5 lines with 12 columns Papa.parse('1,"B\nB",C,A,"B\nB",C,A,"B\nB",C,A,"B\nB",C\n2,"B\nB",C,A,"B\nB",C,A,"B\nB",C,A,"B\nB",C\n3,"B\nB",C,A,"B\nB",C,A,"B\nB",C,A,"B\nB",C\n4,"B\nB",C,A,"B\nB",C,A,"B\nB",C,A,"B\nB",C\n5,"B\nB",C,A,"B\nB",C,A,"B\nB",C,A,"B\nB",C',
{skipFirstNLines: 5}) skips the "real" first line (5 because \n after each line). |
@janisdd It will be great if you can fill an issue/merge request to make this work with quotes also. |
Well, no... I don't think this feature should be added to the library. Here are my thoughts:
However, here are some notes if someone wants to implement it anyway:
I'm not sure if this would also work for streaming/chunking (or whatever, I just use the normal parsing). But as far as i know there is only one core logic/function for the actual parsing... which means this should also work for streaming |
I think this feature hasn't been implemented as wanted in the referenced issue #738 !
Expected output should be (to be fair, it wasn't precisely specified):
But the actual output with
Analogue to the following test case in the code:
This test case is not realistic because it does not reflect a CSV with some preamble lines to be skipped. 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 @bhuvaneshwararaja, @pokoli could you please take a look at it and give me some feedback about my thoughts? :) |
Issues No : #738
Description:
In this feature enhancement, Added the capability to skip a defined number of lines when converting a CSV (Comma-Separated Values) file to JSON format. This functionality offers users more flexibility when dealing with CSV files with header information or metadata at the beginning, allowing for a more efficient and precise conversion process.
Changes Made:
Test cases:
Included test cases to validate the functionality of the skipFirstNLines feature, ensuring that it behaves correctly under various scenarios.
Test 1: "Skip First N number of lines , with header",
Test 2: "Skip First N number of lines , without header",
Test 3: "Skip First N lines with value as 0 with header false",
Test 4: "Skip First N lines with value as 0 with header true",
Test 5: "Skip First N lines with value less then 0, with header true",
Test 6: "Without Skip First N Lines config",