This question already has an answer here:
- Export CSV for Excel 4 answers
I'm trying to create a new CSV from another with PHP .
The results i get is what i need, except the organisation of the CSV .
I don't want a header and i need to separate the fields by column.
I want to get something like this :
A B C
T4004XDUHF210 14.55 40
I'm getting :
A
article_id,2.50,availability
T4004XDUHF210,14.55,40
MSME10/1-ZS10,14.64,58
R3506XKIKT501,14.86,49
T3506XDUHF207,14.86,40
R4103504XKIKT602,14.86,40
My PHP Code :
$outputfp = fopen('new.csv', 'w');
if (($inputfp = fopen("temp/tmp/138702_fr.csv", "r")) !== FALSE) {
while (($data = fgetcsv($inputfp, 1000, "|")) !== FALSE) {
$line = array();
// SKU
$line[]=$data[1];
// Price
$price_calcul=(($data[4]*0.20)+$data[4])+2.5;
$line[] = number_format($price_calcul,2);
// Quantity
$line[]=$data[9];
fputcsv($outputfp, $line);
}
// Clean up
fclose($inputfp);
fclose($outputfp);
}
So i don't need article_id,2.50,availability and i want tabs delimited.
</div>