2

A dataframe in Spark can be created from an external file. Is there a way to use multiple files to create a single object?

EX: If I have say a csv files or parquet files that record the same data (say the counts of an item purchased on a day of the week). Is there a way to initialize a single dataframe from each day's file to get a single dataframe that represents the data of a week's purchases?

1 Answer 1

2

The way spark reads input from a file depends on the underlying Hadoop API's. This means quite often that they extend the same usage, including being able to handle compressed files, or multiple files.

In your case, you would just provide a file input using a wildcard or separated individually by comma. See How to read multiple text files into a single RDD?

Sign up to request clarification or add additional context in comments.

2 Comments

If I provided a folder name with one type of file, would Spark be able to take in all the data in said folder?
Yes, assuming you can all parse them the same way, using following path specifier: "/my/own/path/*"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.