Skip to content

Commit

Permalink
Handle reading encrypted Energy Balances (#551)
Browse files Browse the repository at this point in the history
* Updated the energy-balance reader to check for .encrypted.csv files as well

* Minor fix in check for existing file

---------

Co-authored-by: Kyra de Haan <[email protected]>
  • Loading branch information
louispt1 and kndehaan authored Oct 18, 2024
1 parent e59834c commit 5a11018
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/lib/dataset_source/entso/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,16 @@ def self.energy_balance(csv_table)
end

def self.from_dataset(dataset)
new(dataset.geo_id, Rails.root.join('data', 'datasets', "#{dataset.geo_id}_energy_balance_enriched.csv"))
base_path = Rails.root.join('data', 'datasets', "#{dataset.geo_id}_energy_balance_enriched")
paths = ["#{base_path}.csv", "#{base_path}.encrypted.csv"]

path = paths.find { |p| ::File.exist?(p) }

unless path
raise "Neither the CSV nor the encrypted file exists for dataset with geo_id: #{dataset.geo_id}"
end

new(dataset.geo_id, path)
end

def initialize(geo_id, path)
Expand Down

0 comments on commit 5a11018

Please sign in to comment.