Skip to content

Commit

Permalink
Update foreign key example
Browse files Browse the repository at this point in the history
  • Loading branch information
simnh committed Jun 18, 2019
1 parent 536f72d commit 20f639b
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name;type;capacity;bus;profile;output_parameters;input_parameters;carrier;tech;amount;max
coal;dispatchable;100000;bus0;dispatchable-profile;{"max": 10};{};coal;st;Infinity;""
demand;load;Infinity;bus0;electricity-load-profile;{};{};electricity;load;10;max-profile
name;type;capacity;bus;profile;output_parameters;input_parameters;carrier;tech;amount;marginal_cost
coal;dispatchable;100000;bus0;dispatchable-profile;{"min": 0};{};coal;st;Infinity;marginal-cost-coal
demand;load;Infinity;bus0;electricity-load-profile;{};{};electricity;load;10;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
timeindex,max-profile
timeindex,marginal-cost-coal
2011-01-01T00:00:00Z,10
2011-01-01T01:00:00Z,20
2011-01-01T02:00:00Z,30
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "oemof-tabular-foreignkeys-examples",
"profile": "tabular-data-package",
"name": "oemof-tabular-foreignkeys-examples",
"resources": [
{
"name": "component",
"mediatype": "text/csv",
"format": "csv",
"path": "data/elements/component.csv",
"profile": "tabular-data-resource",
"name": "component",
"format": "csv",
"mediatype": "text/csv",
"encoding": "utf-8",
"schema": {
"fields": [
{
Expand Down Expand Up @@ -61,39 +62,45 @@
"format": "default"
},
{
"name": "max",
"name": "marginal_cost",
"type": "string",
"format": "default"
}
],
"missingValues": [
""
],
"primaryKey": "name",
"foreignKeys": [
{
"fields": "bus",
"reference": {
"resource": "bus",
"fields": "name"
},
"fields": "bus"
}
},
{
"fields": "profile",
"reference": {
"resource": "component_profile"
},
"fields": "profile"
}
},
{
"fields": "marginal_cost",
"reference": {
"resource": "marginal_cost_profile"
}
}
],
"primaryKey": "name",
"missingValues": [
""
]
},
"encoding": "utf-8"
}
},
{
"name": "bus",
"mediatype": "text/csv",
"format": "csv",
"path": "data/elements/bus.csv",
"profile": "tabular-data-resource",
"name": "bus",
"format": "csv",
"mediatype": "text/csv",
"encoding": "utf-8",
"schema": {
"fields": [
{
Expand All @@ -112,19 +119,19 @@
"format": "default"
}
],
"primaryKey": "name",
"missingValues": [
""
]
},
"encoding": "utf-8"
],
"primaryKey": "name"
}
},
{
"name": "max",
"mediatype": "text/csv",
"format": "csv",
"path": "data/sequences/max.csv",
"path": "data/sequences/marginal_cost_profile.csv",
"profile": "tabular-data-resource",
"name": "marginal_cost_profile",
"format": "csv",
"mediatype": "text/csv",
"encoding": "utf-8",
"schema": {
"fields": [
{
Expand All @@ -133,23 +140,23 @@
"format": "default"
},
{
"name": "max-profile",
"name": "marginal-cost-coal",
"type": "integer",
"format": "default"
}
],
"missingValues": [
""
]
},
"encoding": "utf-8"
}
},
{
"name": "component_profile",
"mediatype": "text/csv",
"format": "csv",
"path": "data/sequences/component_profile.csv",
"profile": "tabular-data-resource",
"name": "component_profile",
"format": "csv",
"mediatype": "text/csv",
"encoding": "utf-8",
"schema": {
"fields": [
{
Expand All @@ -171,8 +178,7 @@
"missingValues": [
""
]
},
"encoding": "utf-8"
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from datapackage_utilities import building
"""
Note: This script allow does not create meta data that are valid, you will
need to set the foreign keys for the marginal_cost yourself.
"""
from oemof.tabular.datapackage import building



building.infer_metadata(package_name='oemof-tabular-foreignkeys-examples',
foreign_keys={
Expand Down

0 comments on commit 20f639b

Please sign in to comment.