@@ -2410,6 +2410,7 @@ def generate_resource(
24102410 datecol : int | str | None = None ,
24112411 yearcol : int | str | None = None ,
24122412 date_function : Callable [[dict ], dict | None ] | None = None ,
2413+ no_empty : bool = True ,
24132414 ) -> tuple [bool , dict ]:
24142415 """Write rows to file and create resource, adding it to the dataset. The headers
24152416 argument is either a row number (rows start counting at 1), or the actual
@@ -2440,9 +2441,10 @@ def generate_resource(
24402441 columns: Columns to write. Defaults to all.
24412442 format: Format to write. Defaults to csv.
24422443 encoding: Encoding to use. Defaults to None (infer encoding).
2443- datecol: Optional[Union[int, str]] = None,
2444- yearcol: Optional[Union[int, str]] = None,
2445- date_function: Optional[Callable[[Dict], Optional[Dict]]] = None,
2444+ datecol: Date column for setting time period. Defaults to None (don't set).
2445+ yearcol: Year column for setting dataset year range. Defaults to None (don't set).
2446+ date_function: Date function to call for each row. Defaults to None.
2447+ no_empty: Don't generate resource if there are no data rows. Defaults to True.
24462448
24472449 Returns:
24482450 (True if resource added, dictionary of results)
@@ -2504,6 +2506,7 @@ def process_row(row: Sequence | Mapping) -> Sequence | Mapping | None:
25042506 format = format ,
25052507 encoding = encoding ,
25062508 row_function = process_row ,
2509+ no_empty = no_empty ,
25072510 )
25082511 if not rows :
25092512 logger .error (f"No data rows in { filename } !" )
@@ -2731,6 +2734,7 @@ def download_generate_resource(
27312734 datecol : int | str | None = None ,
27322735 yearcol : int | str | None = None ,
27332736 date_function : Callable [[dict ], dict | None ] | None = None ,
2737+ no_empty : bool = True ,
27342738 ** kwargs : Any ,
27352739 ) -> tuple [bool , dict ]:
27362740 """Download url, write rows to csv and create resource, adding to it
@@ -2769,9 +2773,10 @@ def download_generate_resource(
27692773 columns: Columns to write. Defaults to all.
27702774 format: Format to write. Defaults to csv.
27712775 encoding: Encoding to use. Defaults to None (infer encoding).
2772- datecol: Optional[Union[int, str]] = None,
2773- yearcol: Optional[Union[int, str]] = None,
2774- date_function: Optional[Callable[[Dict], Optional[Dict]]] = None,
2776+ datecol: Date column for setting time period. Defaults to None (don't set).
2777+ yearcol: Year column for setting dataset year range. Defaults to None (don't set).
2778+ date_function: Date function to call for each row. Defaults to None.
2779+ no_empty: Don't generate resource if there are no data rows. Defaults to True.
27752780 **kwargs: Any additional args to pass to downloader.get_tabular_rows
27762781
27772782 Returns:
@@ -2797,6 +2802,7 @@ def download_generate_resource(
27972802 datecol = datecol ,
27982803 yearcol = yearcol ,
27992804 date_function = date_function ,
2805+ no_empty = no_empty ,
28002806 )
28012807
28022808 def download_and_generate_resource (
0 commit comments