Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisguitarguy/4dea280ddc2d9ff62991 to your computer and use it in GitHub Desktop.
Save chrisguitarguy/4dea280ddc2d9ff62991 to your computer and use it in GitHub Desktop.
<?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