Closed nozavroni closed 7 years ago
I'm going to go with the latter solution for now. If I find that people are expecting a CSVelte::import()
method just because there's a CSVelte::export()
, then maybe I'll consider adding it. But I want to be careful about just adding random methods in the library as a whole, but especially within the CSVelte class. I do not want that class to become cluttered and ridiculous.
Added to version 0.2... needs documentation and unit testing too...
Fixed, tested, documented.
Probably the most common use case for CSVelte would be somebody that simply needs to read a CSV file into a PHP array. Currently, CSVelte has no simple way of doing that. This is how you would read a CSV file into an array with CSVelte (as-is):
Possible solutions
Add a
CSVelte::import($filename, $flavor)
methodCould also be called
importToArray()
orreadToArray()
orgetAsArray()
, but the point is, this would be the counter to theCSVelte::export()
method. It would do, basically, the opposite. Read a CSV source, and produce a PHP array.Add a
Reader::asArray()
methodCould also be called
toArray()
orbuildArray()
or any number or other names. But the point is, you wouldn't have to traverse the file/dataset manually just to produce a simple array.