I’ve got a script that reads in from a CSV file and sometimes the CSV files it receives contains an uneven amount of delimiters/columns so the first row could have 30 columns, the 2nd could have 20, etc. I can think of a few solutions myself ie:
Count the delimiters in the widest row, then append the proper amount to each row that is short to make them even.
But I was wondering if anyone had a more elegant method of doing this.
It depends on what you are using to read the CSV the most elegant have seen is
fgetcsvPlease see http://www.php.net/manual/en/function.fgetcsv.php for more informationThere is an example there that counts number of CSV: