Created
July 13, 2023 13:50
-
-
Save AdrianoPereira/1f5ca8ae989dbc30c0cfa9417f566dd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read the GRIB file into a DataFrame | |
grib_df = spark.read.format("binaryFile").option("pathGlobFilter", "*.grb").load("/path/to/grib/file.grb") | |
# Define a function to read the GRIB file using cfgrib | |
def read_grib_file(file_path): | |
with cfgrib.open_file(file_path) as ds: | |
# Read the GRIB data into a pandas DataFrame | |
grib_data = ds.to_dataframe() | |
return grib_data | |
# Read the GRIB file using the defined function | |
grib_data = grib_df.rdd.map(lambda row: read_grib_file(row.path)).collect() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment