Skip to content

Instantly share code, notes, and snippets.

@adamgreenhall
Created February 9, 2012 20:15
Show Gist options
  • Save adamgreenhall/1782772 to your computer and use it in GitHub Desktop.
Save adamgreenhall/1782772 to your computer and use it in GitHub Desktop.
pyomo - loading data from csv
time wind
1:00 50
2:00 52
3:00 53
from coopr.pyomo import *
model = AbstractModel('test data loading model')
# An unordered set of arbitrary objects
model.time = Set()
# A single-dimension parameter
model.wind = Param(model.time,within=PositiveReals)
#model.pprint()
data = ModelData(model=model)
data.add('time.csv', format='set', set='time')
data.add('data.csv', index=['time'], param=['wind'])
data.read(model)
instance = model.create(data)
instance.pprint()
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
time
1:00
2:00
3:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment