From CSV

Reading from a CSV file is equally simple:

sample_data_csv = (
spark
.read
.csv(
'../Data/DataFrames_sample.csv'
, header=True
, inferSchema=True)
)

The only additional parameters passed make sure that the method treats the first row as column names (the header parameter) and that it will attempt to assign the right datatype to each column based on the content (the inferSchema parameter assigns strings by default).

In contrast to reading the data from a JSON-formatted file, reading from a CSV file preserves the order of columns.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset