Bug #72945 [NEW]: CSV Cannot be read properly

From: Date: Fri, 26 Aug 2016 09:16:44 +0000
Subject: Bug #72945 [NEW]: CSV Cannot be read properly
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203563@lists.php.net to get a copy of this message
From:             alex at shopblocks dot com
Operating system: Mac OS X
PHP version:      7.0.10
Package:          *General Issues
Bug Type:         Bug
Bug description:CSV Cannot be read properly

Description:
------------
fgetcsv is not correctly getting all of the rows for a CSV file

Test CSV file:

https://gist.github.com/shopblocks/f5aadf8c9f6cc512471393d4053c66bb

As you can see, the file is valid and imports correctly into GitHub, OS
X Numbers and Excel.



Test script:
---------------
<?php
function dd()
{
    echo '<pre>';
    array_map(function ($x) {
        print_r($x);
    }, func_get_args());

    die(1);
}

$csv = fopen("test.csv", 'r');

$headers = fgetcsv($csv);
$row = fgetcsv($csv);

dd($headers, $row);

Expected result:
----------------
All 21 columns should be filled

Actual result:
--------------
only 15 columns get filled


Array
(
    [0] => id
    [1] => name
    [2] => variants
    [3] => sku
    [4] => price_web
    [5] => price_rrp
    [6] => price_cost
    [7] => quantity
    [8] => visible
    [9] => status
    [10] => tax_id
    [11] => images
    [12] => price_prefix
    [13] => price_modifier
    [14] => text
    [15] => product_video
    [16] => tax_rate
    [17] => attribute
    [18] => attribute_value
    [19] => manufacturer
    [20] => category_id
)
Array
(
    [0] => 1009
    [1] => Halcyon Scout Light
    [2] => Add a Boltsnap§90mm Stainless Steel Boltsnap§+4.0743
    [3] => HalcyonScout
    [4] => 121.6667
    [5] => 121.667
    [6] => 0.000
    [7] => 1
    [8] => 1
    [9] => 0
    [10] => 1
    [11] => 9282§Halcyon_Scout_Light.jpg§Halcyon_Scout_Light.jpg
    [12] => +
    [13] => 4.0743
    [14] => 
Several Halcyon products evolved out of necessity: the  performance of
available manufactured gear was not acceptable under rigorous  mission
critical situations. The Scout is just such a product. 

The Scout  is machined out of a solid rod of delrin for strength and
fitted with a proper  voltage bulb to reduce the risk of failure. Nearly
all widely available reserve  lights overdrive the bulb to create a
brighter beam. While overdriving the bulb  is effective for short term
use, it increases the stress on the filament,  resulting in a greater
frequency of bulb failure. 

The Scout has a  machined attachment point at the rear of the light and
is free from all the  plastic clips and other assorted snags typically
present on mass manufactured  lights. 
 
Specifications: 



Machined from a solid rod of delrin 

5.5 watt bulb 

Approx 3.5 hour burn time 

Uses 3 x C cell batteries (not included)



)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=72945&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=72945&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=72945&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=72945&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=72945&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=72945&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=72945&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=72945&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=72945&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=72945&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=72945&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=72945&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=72945&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=72945&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72945&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=72945&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=72945&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=72945&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72945&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=72945&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=72945&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#203563) next »