Changing the order of columns in a CSV export

Labels

This Discussion is public

Notifications

Hi All,

I am aware of a filter to reduce the number of columns in a CSV file but need some code to change the order of the columns.

Here is the link to the filter for reducing the columns.  https://formidableforms.com/knowledgebase/frm_csv_columns/

Apparently something needs to be done with the array $headings.  but I'm at a loss how to do this, or where.

If you've had success with this before I'd love to hear from you.

Kind Regards,

John.

 

PHP has quite a few array sorting functions, including several for user defined sorting. http://php.net/manual/en/array.sorting.php

You could probably use the filter to intercept the headings array and try sorting it somehow, but I suspect you may be better off intercepting it and redefining it from scratch. In other words, empty it out and redefine it.

Hi Victor,

Thanks for your reply.  That's probably a bit beyond my skill set right now.  I did have a poke around to see where $headings exist and how it is constructed/managed.  But got lost.

Other options for changing the order of the columns rely on Views or datatables and have the results brought to the browser.  My worry with this is that as the dataset grows it might break the browser.  So a backend solution is preferable.

Thanks again for your time.

John.

 

I don't think you have to worry about overloading the browser with either views or datatables. Both use Ajax and pull data as needed. You'll never download an entire database of content at one time. I've built views with datatables that have had over 100 fields that the client required for export, but we only displayed about 10 of the fields on the screen. All the rest were hidden.

Reply to this Discussion