Dear all,
I have been using 6-7 years ago php to create web pages but since then I have worked anymore with php (and that is the reason today I am at point zero).
I would like to read a csv file that is tab delimited and the entries look like
Airwave AAS001 ST5739166513 59 TETRA 400 Directional
I would like to parse all rows and get elements 1 and 3 (columns if you like)
and then write those two columns back in a new csv file (I would call a transformation function for element 3 before restoring it).
What I was able to do myself is to read the csv file
[php]
require ‘./gridrefutils.php’;
$fileCsv=file_get_contents("./SitefinderMay2012.csv");
$csv=explode("\t",$fileCsv);
foreach ($csv as $row){
$array[]=$row;
}
echo "The thrid element is : ".$csv[2];
var_dump($array);
[/php]
the line
[php]echo "The thrid element is : ".$csv[2];[/php]
looks to print only the third element of the last row and not the whole element column
I was also able with the
[php]var_dump($array);[/php]
to confirm that I read successfulyy the whole csv file.
Any ideas on how to proceed?
I summarize:
- Read elements one and three and
- write them back to a new csv file (replace content files everytime code runs)
Any ideas or comments?
Regards
Alex