简体   繁体   English

如何从 S3 的 Pyspark 子文件夹中创建一个新的 dataframe 和 CSV 文件

[英]How to create a new dataframe with CSV file from a folder with subfolders in Pyspark in S3

Hi I'm very new to Pyspark and S3.您好,我是 Pyspark 和 S3 的新手。 I have problem at hand.我手头有问题。 I have a folder, which consists of subfolders and files and also files from the subfolder(all CSVs) i need to create a new dataframe or a csv file where i get contents of the files and create as a single file.我有一个文件夹,其中包含子文件夹和文件以及子文件夹中的文件(所有 CSV)我需要创建一个新的 dataframe 或 csv 文件,我在其中获取文件的内容并创建为单个文件。 Which later need to be read to a table in postgress稍后需要将其读取到 postgress 中的表中

Can anyone please help me.谁能帮帮我吗。 I have code in python, but not sure how to go about with pyspark and S3我在 python 中有代码,但不确定 go 与 pyspark 和 S3 的关系

Try with this option .试试这个选项

recursiveFileLookup – recursively scan a directory for files. recursiveFileLookup – 递归扫描目录中的文件。 Using this option disables partition discovery.使用此选项禁用分区发现。

df = spark.read.option("header","true").option("recursiveFileLookup","true").csv("s3://path/to/root/")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 S3 读取 a.txt 文件并将生成的 dataframe 用作 pyspark 中的 SQL 查询 - How to read a .txt file from S3 and use the resulting dataframe as a SQL query in pyspark 无法在 AWS 上的 EC2 实例上从 S3 读取 csv 到 pyspark dataframe - Can't read csv from S3 to pyspark dataframe on a EC2 instance on AWS pyspark dataframe 在 s3 中写入两次 csv 文件 - pyspark dataframe writing csv files twice in s3 Pyspark 使用自定义名称在 S3 中写入 DataFrame 到 csv 文件 - Pyspark write a DataFrame to csv files in S3 with a custom name pyspark中如何动态创建S3 bucket - How to create S3 bucket dynamically in pyspark 如何将pyspark dataframe直接写入S3 bucket? - How to write pyspark dataframe directly into S3 bucket? 如何使用 Glue 作业将 JSON 从 s3 转换为 CSV 文件并将其保存在同一个 s3 存储桶中 - How to convert JSON to CSV file from s3 and save it in same s3 bucket using Glue job Pyspark Dataframe 从具有当前日期的可变路径的 S3 读取 - Pyspark Dataframe read from S3 with variable path with current date 如何访问 s3 中创建的文件夹以将 csv 文件写入其中? - How can I access the created folder in s3 to write csv file into it? Amazon S3 boto - 如何创建文件夹? - Amazon S3 boto - how to create a folder?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM