从CSV文件中读出数据

PHP程序设计语言和相关项目讨论
Post Reply
User avatar
IOsetting
论坛管理员
论坛管理员
Posts: 3645
Joined: 2006-10-17 1:48

从CSV文件中读出数据

Post by IOsetting » 2008-08-26 18:03

Code: Select all

$opendataPath = "test.csv";
$fp = fopen($opendataPath, "r") or die("error");

$n = 0;
while($row = fgetcsv($fp, 1024))
{
	echo 'No.' . $n . ': ';
	foreach($row as $column)
	{
		echo $column.", ";
	}
	echo "<br/>";
	$n ++;
}

fclose($fp);
对于非常大的csv文件, 可以通过在命令行下执行PHP来完成.

User avatar
fanisky
技术组成员
技术组成员
Posts: 510
Joined: 2007-04-15 15:03

Re: 从CSV文件中读出数据

Post by fanisky » 2008-08-29 16:31

:geek: :geek:

Post Reply