Warning in php with csv -
this code
<?php ini_set("display_errors", true); $inputfilename = 'hw8.csv'; $outputfilename = 'hw8.xml'; // open csv read $inputfile = fopen($inputfilename, 'rt'); // headers of file $headers = fgetcsv($inputfile); // create new dom document pretty formatting $doc = new domdocument(); $doc->formatoutput = true; // add root node document $root = $doc->createelement('rows'); $root = $doc->appendchild($root); // loop through each row creating <row> node correct data while (($row = fgetcsv($inputfile)) !== false) { $container = $doc->createelement('row'); // $i array index (0,1,2,..) , $header value @ $i foreach ($headers $i => $header) { $child = $doc->createelement($header); $child = $container->appendchild($child); $value = $doc->createtextnode($row[$i]); $value = $child->appendchild($value); } $root->appendchild($container); } echo $doc->savexml();
and got warning warning: fopen(input2.csv) [function.fopen]: failed open stream: no such file or directory in /users/csegrad/csv.php on line 9
warning: fgetcsv() expects parameter 1 resource, boolean given in /users/csegrad/csv.php on line 12
warning: fgetcsv() expects parameter 1 resource, boolean given in /users/csegrad/csv.php on line 23
warning: invalid argument supplied foreach() in /users/csegrad/csv.php on line 28
Comments
Post a Comment