Skip to content

Commit

Permalink
made new updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Anu-Ra-g committed Jun 27, 2024
1 parent 678d1a7 commit c6b9e1b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions kerchunk/grib2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
from collections import defaultdict
from typing import Iterable, List, Dict, Set, Optional
import pandas as pd
import gcsfs
import s3fs


import ujson

Expand Down Expand Up @@ -615,7 +612,14 @@ def parse_grib_idx(
for line in f.readlines():
try:
idx, offset, date, attrs = line.split(":", maxsplit=3)
splits.append([int(idx), int(offset), date, attrs])
splits.append(
[
int(idx),
int(offset),
f"{date[2:6]}-{date[6:8]}-{date[8:10]}-{date[10:]}",
attrs,
]
)
except ValueError:
# Wrap the ValueError in a new one that includes the bad line
# If building the mapping, pick a different forecast run where the idx file is not broken
Expand All @@ -638,7 +642,7 @@ def parse_grib_idx(
tstamp = pd.Timestamp.now()
result.loc[:, "indexed_at"] = tstamp

if isinstance(fs, gcsfs.GCSFileSystem):
if fs.protocol[0] == "gs":
result.loc[:, "grib_crc32"] = baseinfo["crc32c"]
result.loc[:, "grib_updated_at"] = pd.to_datetime(
baseinfo["updated"]
Expand All @@ -649,7 +653,7 @@ def parse_grib_idx(
result.loc[:, "idx_updated_at"] = pd.to_datetime(
idxinfo["updated"]
).tz_localize(None)
elif isinstance(fs, s3fs.S3FileSystem):
elif fs.protocol[0] == "s3":
result.loc[:, "grib_Etag"] = baseinfo["ETag"]
result.loc[:, "grib_updated_at"] = pd.to_datetime(
baseinfo["LastModified"]
Expand Down

0 comments on commit c6b9e1b

Please sign in to comment.