Hide empty columns for CSV export

Created on 4 September 2020, over 4 years ago
Updated 25 May 2023, almost 2 years ago

I would like to have the possibility to hide all columns, which has no value at least for one row in CSV export.

Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

🇷🇺Russia kiseleva.t

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇷🇴Romania gge

    Hello,

    Just tried #2 and for me is working in case of batch processing.

    Thank you~

  • 🇧🇴Bolivia manuvelasco Bolivia

    patch #2 works for me with a batch configuration.
    Thank you so much.

  • Status changed to Needs review about 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    3 pass
  • 🇮🇳India chaitanyadessai Goa

    Please review patch.

  • 🇮🇳India chaitanyadessai Goa

    chaitanyadessai changed the visibility of the branch 3169049-7 to hidden.

  • Merge request !35Hide empty columns. → (Open) created by chaitanyadessai
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    3 pass
  • 🇬🇷Greece vensires

    @chaitanyadessai, patch from #2 seems to work fine in latest views_data_export stable version. Is your patch maybe based on top of the -dev version? I believe we can set it as RTBC but just wanted to clarify this one for the maintainers to know what to merge.

  • 🇬🇷Greece vensires

    I tested both patches with the batch implementation and they fail to work properly. Whether this works or not depends on the row values of each batch. If no values exist at all in a specific column, it does get hidden. But if the first batch has values and the second hasn't, then the second set's columns are shifted. This is especially visible if there are other columns with values next to the one being hidden.

    To be honest, I personally can't guess any possible way to implement this in batch without possible performance issues.

  • 🇬🇧United Kingdom steven jones

    To be honest, I personally can't guess any possible way to implement this in batch without possible performance issues.

    I think you'd need to change the architecture of this a decent amount. You'd do all the writing, keeping all the columns, and then before serving up the file for download, you'd iterate over all lines of the file checking to see if any of the cells on that line are non-empty. After reading all lines, you'd know which columns were completely empty.
    Then you'd go back over and remove those columns from each row.
    Painful, but should be doable within PHP memory limits if one is careful to not load the entire file in memory all at once.

    Maybe for the 1.x branch we should only support removing empty columns in non-batched mode, and work on the post-processing pipeline described above a later version?

  • 🇬🇷Greece vensires

    I believe we could go on with this issue for the standard mode, yes. I set it as "Needs Review" but it could be "RTBC" too.

    Just one question to answer:
    Do we need anything extra (change README.md, inline comment, extra validation etc) to mention that the implementation targets the Standard export mode only? Or is it just... discovered by anyone trying?

  • 🇬🇧United Kingdom steven jones

    Yeah, I think we should make it clear in the views UI that the removal of empty columns only works in non-batched mode.

Production build 0.71.5 2024