-
-
Save chrisguitarguy/4dea280ddc2d9ff62991 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require __DIR__ . '/vendor/autoload.php'; | |
$s3 = Aws\S3\S3Client::factory($config); | |
$s3->registerStreamWrapper(); | |
$url = 's3://{$bucket}/{$key}'; | |
// Read CSV with fopen | |
$file = fopen($url, 'r'); | |
$keys = fgetcsv($file); | |
while (!feof($file)) { | |
$row = array_combine($keys, fgetcsv($file)); | |
print_r($row); | |
} | |
// Read CSV with SplFileObject | |
$file = new \SplFileObject($url, 'r'); | |
$keys = $file->fgetcsv(); | |
while (!$file->eof()) { | |
$row = array_combine($keys, $file->fgetcsv()); | |
print_r($row); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment