所以我不知道如何解决这个问题,以便在缺少字段时写入NULL或零(对于count)而不是不创建stats_file:
$stat_file = fopen("./".$feed_id_str."/"."stats.csv", 'w');
$stat_arr = [];
$stat_arr[] = $feed_id;
$stat_arr[] = $like_count_column;
$stat_arr[] = $comment_count_column;
$stat_arr[] = $comment_count_column;
fputcsv($stat_file, $stat_arr);
//fputcsv($stat_file, array($feed_id, $like_count_column, $comment_count_column, count($likers_and_commenters)));
1014185579136663000_1930504334
文件夹就是这种情况。
结果如下:
mona@pascal:~/computer_vision/Instagram-API/test$ tree *_19*
1001637184153042399_1930504334
├── 1001637184153042399_1930504334.jpeg
├── caption.txt
├── commenters.txt
├── comments.txt
├── likers.txt
└── stats.csv
1011842647423434230_1930504334
├── 1011842647423434230_1930504334.jpeg
├── caption.txt
├── commenters.txt
├── comments.txt
├── likers_and_commenters.txt
├── likers.txt
└── stats.csv
1014184930034564556_1930504334
├── 1014184930034564556_1930504334.jpeg
├── caption.txt
├── commenters.txt
├── comments.txt
├── likers_and_commenters.txt
├── likers.txt
└── stats.csv
1014185579136663000_1930504334
├── 1014185579136663000_1930504334.jpeg
├── caption.txt
└── likers.txt
1037815588254367018_1930504334
├── 1037815588254367018_1930504334.jpeg
├── caption.txt
├── commenters.txt
├── comments.txt
├── likers_and_commenters.txt
├── likers.txt
└── stats.csv
998075460065934859_1930504334
├── 998075460065934859_1930504334.jpeg
├── caption.txt
├── commenters.txt
├── comments.txt
├── likers_and_commenters.txt
├── likers.txt
└── stats.csv