Aws-data-wrangler: How to extract Column header from parquet files

Created on 13 May 2020  路  3Comments  路  Source: awslabs/aws-data-wrangler

I am trying to read from a parquet file that is in S3 source bucket and write/create a CSV in the target S3 bucket. I am using a Lambda function to achieve this. While I am able to successfully convert the files from parquet to csv and get the data, I am not getting the column names in the target CSV file. May I know if there is a way to do this. I am using the below modes:

source = wr.s3.read_parquet(path=sourcepath, dataset=True)
wr.s3.to_csv(df=source, path=destination_path, dataset=True,mode = 'overwrite', index = False)

question

Most helpful comment

I have implemented your suggestion and it worked as expected. Thank you Igor.

All 3 comments

Hi @ivshvs thanks fo reaching out.

CSV Datasets does not support headers, but you can achieve it passing dataset=False to write a regular file.

You should be good with something like that:

source = wr.s3.read_parquet(path=sourcepath, dataset=True)
wr.s3.to_csv(df=source, path=f"destination_path{file0.csv}", index = False)

Thank Igor for the swift response. I shall try your suggestion and update you.

I have implemented your suggestion and it worked as expected. Thank you Igor.

Was this page helpful?
0 / 5 - 0 ratings