doutong7216
2012-06-05 16:26跳过CSV文件的第一行
I am trying to import a CSV file. Due to the program we use, the first row is basically all headers that I would like to skip since I've already put my own headers in via HTML. How can I get the code to skip the first row of the CSV? (the strpos command is to cut off the first field in all the rows.)
<?php
$row = 1;
if (($handle = fopen("ptt.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
$row++;
for ($c=0; $c < $num; $c++) {
if(strpos($data[$c], 'Finished') !== false) {
$c++;
echo "<TR> <TD nowrap>" . $data[$c] . "</ TD>"; }
Else{
echo "<TD nowrap>" . $data[$c] . "</ TD>";
}
}
}
fclose($handle);
}
?>
- 点赞
- 回答
- 收藏
- 复制链接分享
8条回答
为你推荐
- 读取CSV文件时如何跳过第一行?
- 互联网问答
- IT行业问题
- 编程语言问答
- it技术
- 计算机技术
- 2个回答
- 跳过CSV文件的第一行
- csv
- php
- 8个回答
- python 处理csv或excel文件时遇到空白单元格怎么处理。
- python
- list
- 1个回答
- Spark textFile 不读取文件第一行
- 读取
- textfile
- spark
- 3个回答