code: def _load_cached_data(
      filename, first_date, last_date, now, resource_name, environ=None
  ):
      # Path for the cache.
      path = get_data_filepath(filename, environ)
  
      # If the path does not exist, it means the first download has not happened
      # yet, so don't try to read from 'path'.
      if os.path.exists(path):
          try:
              data = pd.DataFrame.from_csv(path)
              if data.empty:
                  raise ValueError("File is empty.")
              data.index = pd.to_datetime(
                  data.index,
                  infer_datetime_format=True,
                  errors="coerce",
              ).tz_localize("UTC")
              if has_data_for_dates(data, first_date, last_date):
                  return data
  
              # Don't re-download if we've successfully downloaded and written a
              # file in the last hour.
              last_download_time = last_modified_time(path)
              if (now - last_download_time) <= ONE_HOUR:
                  logger.warn(
                      "Refusing to download new {resource} data because a "
                      "download succeeded at {time}.",
                      resource=resource_name,
                      time=last_download_time,
                  )
                  return data
  
          except (OSError, IOError, ValueError) as e:
              # These can all be raised by various versions of pandas on various
              # classes of malformed input.  Treat them all as cache misses.
              logger.info(
                  "Loading data for {path} failed with error [{error}].",
                  path=path,
                  error=e,
              )
  
      logger.info(
          "Cache at {path} does not have data from {start} to {end}.",
          start=first_date,
          end=last_date,
          path=path,
      )
      return None
  
imports: import os
  from collections import OrderedDict
  import logbook
  import pandas
  import pytz
  from pandas_datareader.data import DataReader
  from six import iteritems
  from six.moves.urllib_error import HTTPError
  from catalyst.constants import LOG_LEVEL
  from catalyst.utils.calendars import get_calendar
  from .None import treasuries, treasuries_can
  from .benchmarks import get_benchmark_returns
  from ..utils.deprecate import deprecated
  from ..utils.paths import cache_root, data_root
label_desc: Use image node_id 11 for calling a global function with example usage: _load_cached_data(filename, first_date, last_date, now, resource_name, environ) and returns: None, data, data