Login   Register  
PHP Classes
elePHPant
Icontem

File: csv_test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Waldemar Derr  >  CSV  >  csv_test.php  >  Download  
File: csv_test.php
Role: Example script
Content type: text/plain
Description: This is the example script need the data files
Class: CSV
A class for import comma separated and fixed files
Author: By
Last change: Anpassung an die neue Dump-Funktion
Date: 2003-04-03 10:55
Size: 1,308 bytes
 

Contents

Class file image Download
<?

require("class.csv.php");

echo 
"<p>Import aus der Datei 91002.csv</p>";
$csv_import = new CSVImport;
$csv_import->setFile("091002.csv");
$csv_import->parseCSV();
if(
$csv_import->isOK())
{

    echo 
"Anzahl der Datensätze: <b>" $csv_import->CSVNumRows() . "</b><br>";
    echo 
"Anzahl der Felder: <b>" $csv_import->CSVNumFields() . "</b><br>";
    echo 
"Name des 1.Feldes: <b>" $csv_import->CSVFieldName(0) . "</b><br>";

    
$csv_import->dumpResult();
}




//CSV-Datei mit Festlängen-Werten
echo "<p>Import aus der Datei fixed.csv</p>";
$csv_import2 = new CSVFixImport;
$csv_import2->setFile("fixed.csv");
$csv_import2->addCSVField("Satzart"2);
$csv_import2->addCSVField("Typ"1);
$csv_import2->addCSVField("Gewichtsklasse"1);
$csv_import2->addCSVField("Marke"4);
$csv_import2->addCSVField("interne Nummer"4);


$csv_import2->addFilter("Satzart""==""020"); //Es werden nur die Datensätze gefetcht, die diesem Filter entsprechen
$csv_import2->parseCSV();
if(
$csv_import->isOK())
{


    echo 
"Anzahl der Datensätze: <b>" $csv_import2->CSVNumRows() . "</b><br>";
    echo 
"Anzahl der Felder: <b>" $csv_import2->CSVNumFields() . "</b><br>";
    echo 
"Name des 1.Feldes: <b>" $csv_import2->CSVFieldName(0) . "</b><br>";

    
$csv_import2->dumpResult();
}

?>