I need to remove some columns and the first row from a csv and put the result in a new csv file. I tried already with some sugesstions found here on stack, but none of them will work for me. My csv has 9 columns but i only need 5 of them. The best found solution here to remove the columns seems to be the one i will post below, but i only get commas in the result file and some where some data. The data in my csv are spararted with ';' I hope any one can help me.
Here is the code i played with:
<?php
$input = 'gesamtbestand.csv';
$output = 'mw-stock.csv';
if (false !== ($ih = fopen($input, 'r'))) {
$oh = fopen($output, 'w');
while (false !== ($data = fgetcsv($ih))) {
// this is where you build your new row
$outputData = array($data[1], $data[2], $data[4], $data[5], $data[8]);
fputcsv($oh, $outputData);
}
fclose($ih);
fclose($oh);
}
delimiter