Open MDBenson opened 3 years ago
I am not sure if ParseCsv can handle this. I might research this further once I reserve time for this.
If you have solved it in the mean time: pull requests are welcome.
I mean, in essence all it needs is a method that allows:
$csv->columns = 10;
Or similar to lock the number of columns.
The rest is complex and I agree it's beyond ParseCsv's scope.
Pull requests to improve this library are welcome. 😇
I have a CSV output requirement that is fighting parseCSV's unparse() method something fierce because the data is not a simple flat file, I am reporting a line then a 'subreport' table below that line and then flattening it all into a single CSV e.g.:
The problem I am having is the main titles are only 4 columns and parseCSV is assumingthe CSV is only 4 columns wide and truncating the additional data. When I try to use unparse() or output($file) it's screwing up the subreport data in all sorts of interesting ways, like skipping some of the columns. I have have to add 'phoney' $csv->titles[] elements in that add extra columns, but found these have to be unique and also have to contain text (I can't for example make them a blank space like " ", or just repeated "-" titles).
It would be very beneficial if I could just force parseCSV to respect the maximum width of columns in the data and override it's 'best guess' attempts which are extremely problematic.
Is this possible to dothis already? If not then could it be added?