csvxml/csv_laden_iso.php

35 lines
1.2 KiB
PHP
Raw Normal View History

2019-08-25 21:45:52 +02:00
<?PHP
ob_start();
2019-08-27 00:31:46 +02:00
require_once 'inc/zeichen.php';
$filename = $_GET['fnam'];
$csv_datei = 'csv/' . $filename;
2019-08-25 21:45:52 +02:00
2019-08-27 00:31:46 +02:00
mkdir("xml", 0777);
2019-08-25 21:45:52 +02:00
$fp = fopen ( $csv_datei, 'r' );
$y = 0;
while ( $zeile = fgetcsv ( $fp, 100000, ';' ) )
{
2019-08-27 00:31:46 +02:00
$y++;
$zieldatei = 'xml/' . $y . '.xml';
if (!$handle = fopen($zieldatei, 'w')) {
echo "Cannot open file ($zieldatei)";exit;
}
$somecontent = '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n"; // normal
$somecontent = $somecontent . '<record>' . "\n";
2019-08-25 21:45:52 +02:00
2019-08-27 00:31:46 +02:00
for ($x = 0; $x < count ( $zeile ); $x++)
{
$inhalt[$y][$x] = $zeile[$x];
//if ($inhalt[$y][$x]=='') $inhalt[$y][$x]='ERSATZ';
$somecontent = $somecontent . '<' . tagify(transform($inhalt[1][$x])) . '>' . transform($inhalt[$y][$x]) . '</' . tagify(transform($inhalt[1][$x])) . '>' . "\n"; //normaleinstellung
}
$somecontent = $somecontent . '</record>';
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";exit;
}
fclose($handle);
2019-08-25 21:45:52 +02:00
}
fclose($fp);
2019-08-27 00:31:46 +02:00
echo ($y - 1) . ' files created';
2019-08-25 21:45:52 +02:00
echo '<br><a href="zipit.php"><img src="img/go.gif"> Download as zip</a>';