Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.1K
Visualizações
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.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

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.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda