From 1e106c452744b2630318fa25d61bec35ab2d209d Mon Sep 17 00:00:00 2001 From: Riccardo Boero <ribo@nilu.no> Date: Thu, 4 Apr 2024 10:14:55 +0200 Subject: [PATCH] Added management of missing data in all employment data queries --- src/FACT_jobs.jl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/FACT_jobs.jl b/src/FACT_jobs.jl index 9b3b7af..3dcc197 100644 --- a/src/FACT_jobs.jl +++ b/src/FACT_jobs.jl @@ -139,9 +139,9 @@ function eu_lfs(conn::MySQL.Connection, selection::Dict) # execute result = query_connection(conn, query) if !("industry" in names(result)) - println("No data returned for query with GeoID = $id and Year = $year.") + println("No data returned for query with GeoID = $id and Year = $year.") # Initialize `result` with the expected columns but no rows - #result = DataFrame(industry = String[], jobs = Float64[], geo_id = String[], agg_level = Int[]) + result = DataFrame(industry = String[], jobs = Float64[], geo_id = String[], agg_level = Int[]) end # add geo_id col result[!, :geo_id] = fill(id, nrow(result)) @@ -178,6 +178,11 @@ function eu_sbs(conn::MySQL.Connection, selection::Dict) query = "SELECT Nace as industry, Employment as jobs FROM SBS WHERE Year = "*string(year)*" AND GeoID = '"*id*"';" # execute result = query_connection(conn, query) + if !("industry" in names(result)) + println("No data returned for query with GeoID = $id and Year = $year.") + # Initialize `result` with the expected columns but no rows + result = DataFrame(industry = String[], jobs = Float64[], geo_id = String[], agg_level = Int[]) + end # add geo_id col result[!, :geo_id] = fill(id, nrow(result)) # add agg level @@ -213,6 +218,11 @@ function eu_rea(conn::MySQL.Connection, selection::Dict) query = "SELECT Nace as industry, EmpTh*1000 as jobs FROM REA WHERE Year = "*string(year)*" AND GeoID = '"*id*"';" # execute result = query_connection(conn, query) + if !("industry" in names(result)) + println("No data returned for query with GeoID = $id and Year = $year.") + # Initialize `result` with the expected columns but no rows + result = DataFrame(industry = String[], jobs = Float64[], geo_id = String[], agg_level = Int[]) + end # add geo_id col result[!, :geo_id] = fill(id, nrow(result)) # add agg level -- GitLab