Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
--TEST--
2
File_CSV Test Case 020: First field quoted = last field being excluded
3
--FILE--
4
<?php
5
// $Id: 020.phpt,v 1.3 2007/05/11 21:49:01 cipri Exp $
6
/**
7
 * Test for:
8
 *   - odd quote behaviour in discoverFormat excludes the last field
9
 *     When the first field is quoted and the next field is not then
10
 *     the last field is popped off
11
 *   - Happens because when the first and last/second last fields
12
 *     are quoted but not the middle ones it thinks they are inside the
13
 *     quotes and thus one to few fields but the read process works things
14
 *     out perfectly, only discoverFormat messes up
15
 */
16
 
17
require_once 'File/CSV.php';
18
 
19
$file = dirname(__FILE__) . '/020.csv';
20
$conf = File_CSV::discoverFormat($file);
21
 
22
print "Format:\n";
23
print_r($conf);
24
print "\n";
25
 
26
$data = array();
27
while ($res = File_CSV::read($file, $conf)) {
28
    $data[] = $res;
29
}
30
 
31
print "Data:\n";
32
print_r($data);
33
print "\n";
34
?>
35
--EXPECT--
36
Format:
37
Array
38
(
39
    [fields] => 5
40
    [sep] => ,
41
    [quote] => "
42
)
43
 
44
Data:
45
Array
46
(
47
    [0] => Array
48
        (
49
            [0] => 004343
50
            [1] => Helgi
51
            [2] => Project
52
            [3] => 007
53
            [4] => 008
54
        )
55
 
56
)