Page 1 of 1

csv output

Posted: Wed Jul 07, 2010 9:21 am
by faza
im having problems exporting to csv

$csv_output .= $result['domain'] . "\n" . $result['whois'] . "\n" . $result['dig'] . "\t" . ;

Theres something wrong with this syntax ?

Please help

I need the csv file to each of the results to be in a seperate column and then for it to break to the next line

Re: csv output

Posted: Wed Jul 07, 2010 9:24 am
by AbraCadaver
What does the C in CSV stand for? I don't see any of those. You also have an extraneous . near the end of your string.

Re: csv output

Posted: Wed Jul 07, 2010 10:55 am
by Jade
You know this is the second post in the past what, 3 days, where someone has left the C outta the CSV files. Interesting....

Re: csv output

Posted: Wed Jul 07, 2010 11:21 am
by faza
this is now working had help from a another programmer
$csv_output = "Domain\tWhois\tdig\tavailability\t\n";
$filename = "multi_whois.xls";
foreach ($results as $result){
$whois = str_replace('"', "'", $result['whois']);
$return = str_replace("1", "UNAVAILABLE", $result['availability']).
// $return = $availability

$csv_output .= $result['domain'] . "\t" . '"'. $whois .'"'. "\t" . '"' . $result['dig'] . '"' . "\t" . $return . '"' ."\n";
}

WAS told not to use commas as the data from the whois statment can return commas and then this will break when its exported to csv!

Re: csv output

Posted: Wed Jul 07, 2010 11:37 am
by AbraCadaver
Then that is tab delimited not comma delimited. If you quote text in a CSV file then the commas are not a problem:
[text]"column 1 with a , in it","column 2, with 2 , s in it","etc, etc, etc..."[/text]