I ve got a CSV file with two set of data in it [itsdraed a templogger]. 我很想知道,是否有办法将头两行作为一组数据和其余数据作为第二组数据输入。 我熟悉购买力平价,但从来没有做过这样的事情。 兹附上下一组数据。 任何帮助或方向都将受到高度赞赏。 感谢。
Ajay
Serial Number,Model,Name,Number,Time of Reading,Sample Rate,Start Time
910000000ebeaa4,DS1922T,SRBA04-240909 ,beaa-TNTVLPRP54,9/30/09 16:52,1,9/24/09 18:59
Sample #,Date/Time,Temp ¡F,Temp ¡C,,,
1,"Thu, Sep, 24, 06:59, PM",82.4,28,,,
2,"Thu, Sep, 24, 07:00, PM",83.3,28.5,,,
3,"Thu, Sep, 24, 07:01, PM",83.3,28.5,,,
4,"Thu, Sep, 24, 07:02, PM",83.3,28.5,,,
5,"Thu, Sep, 24, 07:03, PM",83.3,28.5,,,
6,"Thu, Sep, 24, 07:04, PM",83.3,28.5,,,
7,"Thu, Sep, 24, 07:05, PM",83.3,28.5,,,
8,"Thu, Sep, 24, 07:06, PM",83.3,28.5,,,
9,"Thu, Sep, 24, 07:07, PM",83.3,28.5,,,
10,"Thu, Sep, 24, 07:08, PM",83.3,28.5,,,
解决办法
感谢。 [原文照搬]。 非常感谢。
<?php
$fhandle = fopen( 1.csv , r );
$device_header = fgetcsv($fhandle, 1000, , );
$device_data = fgetcsv($fhandle,1000, , );
$device = array_combine($device_header, $device_data);
$data_header = fgetcsv($fhandle,1000, , );
$dataset = array();
while ($data = fgetcsv($fhandle,1000, , )) {
$dataset[] = array_combine($data_header, $data);
}
fclose($fhandle);
?>