Closed GoogleCodeExporter closed 9 years ago
Thanks, oop.coder.
Yes, indeed your right!
I did write some new tests just now and saw your code.
I opted for a different solution. but thanks for submitting the bug anyway.
I changed the simmetrize method, then thing is:
it simetrizes to the longest row, but if the row is empty then it will
do nothing.
so I made it default to the header length when all the rows return zero for
length.
this, solves the problem and passes all previous tests together with three new
ones
that check for array, string, and integers returning a valid appended row to the
collection!
you should see this changes in the next release 2.6
Thanks for contributing!
{{{
public function symmetrize($value = '')
{
$max_length = 0;
foreach ($this->rows as $row) {
$row_length = count($row);
if ($max_length < $row_length) {
$max_length = $row_length;
}
}
if ($max_length == 0) {
$max_length = count($this->headers);
}
foreach ($this->rows as $key => $row) {
$this->rows[$key] = array_pad($row, $max_length, $value);
}
$this->headers = array_pad($this->headers, $max_length, $value);
}
}}}
Original comment by kazu....@gmail.com
on 3 Mar 2009 at 9:41
nice work.
I didn't even think about your symmetrize method.
I like your library, and I am waiting for your next version with
- export (gets altered data as a csv string)
implemented.
If it had a way to change the encoding of the data, it'd be better too.
Original comment by oop.co...@gmail.com
on 4 Mar 2009 at 9:22
Original issue reported on code.google.com by
oop.co...@gmail.com
on 19 Feb 2009 at 10:43