catamphetamine / read-excel-file

Read *.xlsx files in a browser or Node.js. Parse to JSON with a strict schema.
https://catamphetamine.gitlab.io/read-excel-file/
MIT License
301 stars 52 forks source link

Backward compability with v4 #94

Closed codler closed 3 years ago

codler commented 3 years ago

@catamphetamine Hi, could you provide an options in v5 to skip empty lines to make it backward compatible with v4?

catamphetamine commented 3 years ago

Hi. Why don’t you simply update to the latest version.

On Wed, 23 Jun 2021 at 20:35, Han Lin Yap @.***> wrote:

@catamphetamine https://github.com/catamphetamine Hi, could you provide an options in v5 to skip empty lines to make it backward compatible with v4?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/catamphetamine/read-excel-file/issues/94, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADUP346B75T65V2XK4GGWDTUILOZANCNFSM47GII7PQ .

codler commented 3 years ago

Yes, i want to use latest version, but it have big breaking changes, by adding the option , in latest version, to make possible to skip empty lines again would solve this

catamphetamine commented 3 years ago

What changes exactly are an issue?

On Thu, 24 Jun 2021 at 00:12, Han Lin Yap @.***> wrote:

Yes, i want to use latest version, but it have big breaking changes, by adding the option , in latest version, to make possible to skip empty lines again would solve this

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/catamphetamine/read-excel-file/issues/94#issuecomment-867162745, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADUP37NUXBOIGURVRMM3MLTUJE5FANCNFSM47GII7PQ .

codler commented 3 years ago

In v5

readXlsxFile() now doesn't skip empty rows or columns: it only skips empty rows or columns at the end, but not in the beginning and not in the middle as it used to.

catamphetamine commented 3 years ago

@codler Oh, I see: there's no option to skip empty rows now. Can you provide an example of how your Excel file looks like (approximately) and why are there empty rows?

catamphetamine commented 3 years ago

@codler

When using a schema, see transformData function parameter that can remove empty rows: https://github.com/catamphetamine/read-excel-file#transforming-rowscolumns-before-schema-is-applied

readXlsxFile(file, {
  schema,
  transformData(data) {
    // Removes empty rows.
    return data.filter(row => row.filter(column => column !== null).length > 0)
  }
})

When not using a schema, just do:

// Removes empty rows.
data = data.filter(row => row.filter(column => column !== null).length > 0)
codler commented 3 years ago

Seems to work, thank you @catamphetamine !