How to read an .xls file from AWS S3 using spark in java? And unable to read sheetName

Mehaboob Khan

I am trying to read a .xls file from AWS S3 but getting java.io.FileNotFoundException exception.

I tried below two approaches. One by giving the path in option() with key location and another by adding the same path in load() as well.

Dataset<Row> segmentConfigData = spark.read()
                .format("com.crealytics.spark.excel")
                .option("sheetName", "sheet1")
                .option("header","true")
                .option("location","s3a://input/552SegmentConfig.xls")
                .option("useHeader", "true")
                .option("treatEmptyValuesAsNulls", "true")
                .option("inferSchema", "true")
                .option("addColorColumns", "False")
                .load();

Dataset<Row> segmentConfigData = spark.read()
                .format("com.crealytics.spark.excel")
                .option("sheetName", "sheet1")
                .option("header","true")
                .option("location","s3a://input/552SegmentConfig.xls")
                .option("useHeader", "true")
                .option("treatEmptyValuesAsNulls", "true")
                .option("inferSchema", "true")
                .option("addColorColumns", "False")
                .load("s3a://input/552SegmentConfig.xls");

I get file not found an exception. Similarly, when I read .csv file I am able to read the file.

Edit- I have solved this issue. I was using an older version of "com.crealytics.spark.excel". I was able to ready once I ungraded the jar.

But now I am facing another issue. I am unable to read any other sheet other then the first sheet. Any Help?

Mehaboob Khan

I have solved this issue. I was using an older version of "com.crealytics.spark.excel". I was able to ready once I ungraded the jar.

Further, I was just able to read the first sheet of (.xls) file. Below is the code snippet:

spark.read()
    .format("com.crealytics.spark.excel")
    .option("location",path)
    .option("sheetName", sheetName)
    .option("dataAddress", "'"+sheetName+"'!A1")
    .option("header","true")
    .option("useHeader", "true")
    .option("treatEmptyValuesAsNulls", "true")
    .option("inferSchema", "true")
    .option("addColorColumns", "False")
    .load(path);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to read Parquet file from S3 without spark? Java

From Java

How to read parquet file from s3 using dask with specific AWS profile

From Java

Spark read file from S3 using sc.textFile ("s3n://...)

From Java

Read AWS s3 File to Java code

From Java

How to read data from XLS (Excel) file [Java, Android]

From

Read file from aws s3 bucket using node fs

From Dev

Spark: read csv file from s3 using scala

From Dev

How do I upload a CSV file in myBucket and Read File in S3 AWS using Python

From Dev

Read a csv file from aws s3 using boto and pandas

From Dev

AWS Lambda@edge. How to read HTML file from S3 and put content in response body

From Dev

Read the contents of a file from AWS s3 using its Pre-signed URL

From Dev

How to read multiple files from AWS S3 in spark dataframe?

From Dev

Python: How to read and load an excel file from AWS S3?

From Dev

How to read file from AWS s3 in python flask on web

From Dev

How to tell what AWS credentials Spark is using to read S3 files?

From Dev

How to read csv file from s3 bucket in AWS Lambda?

From Dev

How to write a policy in .yaml for a python lambda to read from S3 using the aws sam cli

From Dev

how to create read only and write only token for specific resource for a file in s3 using AWS STS

From Dev

Unable to read csv from S3 using R

From Dev

Read csv file from S3 into spark in R

From Dev

AWS charges for spark read from S3 buckets?

From Dev

How to read file from s3?

From Dev

How to read Snappy Compressed file from S3 in Java

From Dev

How to read AWS S3 images from Sagemaker for processing

From Dev

pyspark read file from AWS S3 not working

From Dev

How to read a text file in S3 bucket from inside an AWS EMR without using spark

From Dev

How to read pickle file from AWS S3 nested directory?

From Dev

How to read and overwrite a file in AWS s3 using Lambda and Python?

From Dev

How to read .dat file from AWS S3 using mdfreader

Related Related

  1. 1

    How to read Parquet file from S3 without spark? Java

  2. 2

    How to read parquet file from s3 using dask with specific AWS profile

  3. 3

    Spark read file from S3 using sc.textFile ("s3n://...)

  4. 4

    Read AWS s3 File to Java code

  5. 5

    How to read data from XLS (Excel) file [Java, Android]

  6. 6

    Read file from aws s3 bucket using node fs

  7. 7

    Spark: read csv file from s3 using scala

  8. 8

    How do I upload a CSV file in myBucket and Read File in S3 AWS using Python

  9. 9

    Read a csv file from aws s3 using boto and pandas

  10. 10

    AWS Lambda@edge. How to read HTML file from S3 and put content in response body

  11. 11

    Read the contents of a file from AWS s3 using its Pre-signed URL

  12. 12

    How to read multiple files from AWS S3 in spark dataframe?

  13. 13

    Python: How to read and load an excel file from AWS S3?

  14. 14

    How to read file from AWS s3 in python flask on web

  15. 15

    How to tell what AWS credentials Spark is using to read S3 files?

  16. 16

    How to read csv file from s3 bucket in AWS Lambda?

  17. 17

    How to write a policy in .yaml for a python lambda to read from S3 using the aws sam cli

  18. 18

    how to create read only and write only token for specific resource for a file in s3 using AWS STS

  19. 19

    Unable to read csv from S3 using R

  20. 20

    Read csv file from S3 into spark in R

  21. 21

    AWS charges for spark read from S3 buckets?

  22. 22

    How to read file from s3?

  23. 23

    How to read Snappy Compressed file from S3 in Java

  24. 24

    How to read AWS S3 images from Sagemaker for processing

  25. 25

    pyspark read file from AWS S3 not working

  26. 26

    How to read a text file in S3 bucket from inside an AWS EMR without using spark

  27. 27

    How to read pickle file from AWS S3 nested directory?

  28. 28

    How to read and overwrite a file in AWS s3 using Lambda and Python?

  29. 29

    How to read .dat file from AWS S3 using mdfreader

HotTag

Archive