Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.1

Request #17201 records ident with getAsymmetricRows() report
Submitted: 2010-03-07 21:11 UTC
From: farell Assigned:
Status: Open Package: File_CSV_DataSource (version 1.0.1)
PHP Version: 5.2.11 OS:
Roadmaps: (Not assigned)    
Subscription  


 [2010-03-07 21:11 UTC] farell (Laurent Laville)
Description: ------------ I've tried File_CSV_DataSource today, and I like it usefull except for report returns by getAsymmetricRows(). I'd like to have directly the record # as key array item for each asymmetric rows. For example, if I use the "File_CSV_DataSource-1.0.1\tests\data\asymmetric.csv" file I would like to know that asymmetrics records are #6 and #9. Test script: --------------- <?php require_once 'File/CSV/DataSource.php'; $csv = new File_CSV_DataSource(); $resp = $csv->load('asymmetric.csv'); if ($resp) { $asymmetric = $csv->getAsymmetricRows(); if (count($asymmetric) > 0) { print_r(array_keys($asymmetric)); } } ?> Expected result: ---------------- array ( 6 => array ( 0 => '5aa', 1 => '5bb', 2 => '5cc', 3 => '5dd', 4 => '5ee', 5 => 'extra1', ), 9 => array ( 0 => '8aa', 1 => '8bb', 2 => '8cc', 3 => '8dd', 4 => '8ee', 5 => 'extra2', ), ) Actual result: -------------- array ( 0 => array ( 0 => '5aa', 1 => '5bb', 2 => '5cc', 3 => '5dd', 4 => '5ee', 5 => 'extra1', ), 1 => array ( 0 => '8aa', 1 => '8bb', 2 => '8cc', 3 => '8dd', 4 => '8ee', 5 => 'extra2', ), )

Comments

 [2010-03-07 21:13 UTC] farell (Laurent Laville)
 [2010-03-07 21:38 UTC] farell (Laurent Laville)
Take care that at end of parse sequence, there is a call to removeEmpty() that gave wrong results with the patch I've provided. For example with csv data file below (notice the blank line between lines 8 and 10) header_a, header_b, header_c, header_d, header_e 1aa, 1bb, 1cc, 1dd, 1ee 2aa, 2bb, 2cc, 2dd, 2ee 3aa, 3bb, 3cc, 3dd, 3ee 4aa, 4bb, 4cc, 4dd, 4ee 5aa, 5bb, 5cc, 5dd, 5ee, extra1 6aa, 6bb, 6cc, 6dd, 6ee 7aa, 7bb, 7cc, 7dd, 7ee 8aa, 8bb, 8cc, 8dd, 8ee, extra2 9aa, 9bb, 9cc, 9dd, 9ee I would like to get asymmetric rows are on line #6 and #10, but I get only #6, #9