php read CSV with various amount of delimiters

Posted by jreed121 on Stack Overflow See other posts from Stack Overflow or by jreed121
Published on 2012-04-02T23:12:52Z Indexed on 2012/04/02 23:28 UTC
Read the original article Hit count: 173

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about php

Related posts about csv