NET_TURNOV TDCLOINDI 290418 256124257 1047126 red 8966 513168 162230 red 2669 this the conntent of my txt file, now i want to read this file in php delete column 2 also delete all rows having red and saved as csv my approach i use fopen($filename,'r'); then i have no clue how to do this job.
best approach is to load as file($FILE) to put the contents into an array then depending whether your csv is a tab, comma etc recurse over the array to do what you need to
Maybe you could try something like this: $lines = file('test_file.txt'); $content=''; foreach($lines as $row){ $temp = explode(' ',$row); if($temp[0] !='red'){ $content .=$temp[0]; } } file_put_contents('out.txt',$content); //PHP 5 function PHP: The output would be NET_TURNOV 290418 256124257 1047126 513168 162230 It’s probably not the best way of doing it but it will work