Skip to content

feat(parser): add comment_lines option to skip header metadata lines#87

Merged
hat0uma merged 1 commit intomainfrom
feat/skip-header-comment-lines
Dec 20, 2025
Merged

feat(parser): add comment_lines option to skip header metadata lines#87
hat0uma merged 1 commit intomainfrom
feat/skip-header-comment-lines

Conversation

@hat0uma
Copy link
Copy Markdown
Owner

@hat0uma hat0uma commented Dec 15, 2025

Summary

  • Add new comment_lines parser option that treats the first N lines as comments regardless of content
  • Useful for CSV files with fixed header/metadata sections (e.g., file info, creation date)
  • Can be combined with existing comments prefix detection

Changes

  • Add comment_lines option to CsvView.Options.Parser
  • Create util.create_is_comment(opts) function to unify comment detection logic
  • Refactor parser to accept comment detection function instead of comment prefixes
  • Update sniffer to use the new comment detection approach

Usage

-- In setup
require('csvview').setup({
parser = {
  comment_lines = 2,  -- Skip first 2 lines as metadata
}
})

-- Or via command line
:CsvViewEnable comment_lines=2

Example:

File: data.csv
Created: 2024-01-01
name,age,city
John,25,New York

Setting comment_lines = 2 will treat the first two lines as comments and parse from line 3.

Close #83

Add a new parser option `comment_lines` that treats the first N lines
of a file as comments regardless of their content. This is useful for
CSV files that have fixed header/metadata sections at the top.

- Add `comment_lines` option to parser configuration
- Create `util.create_is_comment()` to unify comment detection logic
- Refactor parser and sniffer to use the new comment detection function
- Support combining `comment_lines` with existing comment prefix detection
@hat0uma hat0uma merged commit 1f40995 into main Dec 20, 2025
5 checks passed
@hat0uma hat0uma deleted the feat/skip-header-comment-lines branch December 20, 2025 05:23
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

Successfully merging this pull request may close these issues.

Ability to skip first N-lines / treat first N-lines as comments

1 participant