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

feat: update header detection logic #340

Merged
merged 4 commits into from
Dec 6, 2023

Conversation

carlbrugger
Copy link
Contributor

@carlbrugger carlbrugger commented Nov 29, 2023

This PR introduces new header detection options.

Guide: FlatFilers/Guides#962

Usage:

// default
listener.use(
  ExcelExtractor()
)
// or...
listener.use(
  ExcelExtractor({
    headerDetectionOptions: {
      algorithm: 'default',
      rowsToSearch: 30, // Default is 10
    },
  })
)

// explicitHeaders
listener.use(
  ExcelExtractor({
    headerDetectionOptions: {
      algorithm: 'explicitHeaders',
      headers: ['fiRsT NamE', 'LaSt nAme', 'emAil'],
    },
  })
)

// specificRows
listener.use(
  ExcelExtractor({
    headerDetectionOptions: {
      algorithm: 'specificRows',
      rowNumbers: [2], // 0 based
    },
  })
)

@carlbrugger carlbrugger self-assigned this Nov 29, 2023
@carlbrugger carlbrugger requested a review from bangarang December 1, 2023 18:27
// If we have an explicit skip, use it, otherwise skip past the last header row
const skip = this.options.skip ?? maxRow + 1

// TODO: this logic is duplicated, factor it out?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a bunch of the getHeaders logic is shared - wonder if we abstract out just the logical changes that are different here instead of just the return Promise?

@carlbrugger carlbrugger merged commit c93b2d9 into main Dec 6, 2023
4 checks passed
@carlbrugger carlbrugger deleted the feat/update-excel-extractor-header-logic branch December 6, 2023 19:17
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.

2 participants