Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.1K
Vistas
List files in directory on AWS S3 with pyspark/python

So, I am new to AWS S3 and pyspark and linux. I am not sure where to start. Here is my question:

In linux I can issue the following command and can see files in the folder:

aws s3 ls 's3://datastore/L2/parquet'

Doing similar thing with python does not work

import os
os.listdir('s3://datastore/L2/parquet')

It gives error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 2] No such file or directory: 's3://datastore/L2/parquet'

However, pyspark and SQLContext.read.parquet understands it well:

from pyspark.sql import SQLContext
sqlContext = SQLContext(sc)
df = sqlContext.read.parquet('s3://datastore/L2/parquet')

Any reason why it works in SQLContext and does not work in os.listdir? Where can I start to clear my confusion? Any reply besides 'get bachelor in cs' would be helpful.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

So, AWS s3 is not the same as your operating system's file system. The AWS s3 ls command and the pyspark SQLContext.read commands are doing something different from the os.listdir command, which does not know how to read things from s3.

To read things from s3, I recommend looking at the boto3 library, or the s3fs library, which is a wrapper around boto3 that treats s3 more like a filesystem. There are a variety of options within boto3 for listing buckets and files within buckets.

From the s3 docs:

In terms of implementation, buckets and objects are resources, and Amazon S3 provides APIs for you to manage them.

If you don't know how the Linux file system works, I recommend reading about it, maybe something like this will be helpful.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda