@@ -48,7 +48,7 @@ list_parameters(gdx)
4848list_variables (gdx)
4949list_equations (gdx)
5050
51- # Access data as DataFrames
51+ # Access data as Tables.jl-compatible column tables
5252demand = gdx[:demand ] # bracket syntax
5353demand = gdx. demand # property syntax (with tab completion)
5454
@@ -57,17 +57,21 @@ sym = get_symbol(gdx, :demand)
5757sym. name # "demand"
5858sym. description # explanatory text from GAMS
5959sym. domain # ["j"]
60- sym. records # the DataFrame
60+ sym. records # the records table
61+
62+ # Pass DataFrame as a sink to materialize DataFrames while reading
63+ using DataFrames
64+ gdx = read_gdx (" transport.gdx" , DataFrame)
6165```
6266
6367### Writing GDX files
6468
6569``` julia
66- using GDXInterface, DataFrames
70+ using GDXInterface
6771
68- # Write DataFrames as parameters
69- supply = DataFrame ( i = [" seattle" , " san-diego" ], value = [350.0 , 600.0 ])
70- demand = DataFrame ( j = [" new-york" , " chicago" , " topeka" ], value = [325.0 , 300.0 , 275.0 ])
72+ # Write Tables.jl-compatible tables as parameters
73+ supply = (; i = [" seattle" , " san-diego" ], value = [350.0 , 600.0 ])
74+ demand = (; j = [" new-york" , " chicago" , " topeka" ], value = [325.0 , 300.0 , 275.0 ])
7175write_gdx (" output.gdx" , " supply" => supply, " demand" => demand)
7276
7377# Round-trip: read a GDX file and write it back (preserves all symbol types)
@@ -98,17 +102,18 @@ gdx = read_gdx("big_model.gdx", only=[:x, :demand])
98102### Reading
99103
100104``` julia
101- read_gdx (filepath; parse_integers= true , only= nothing ) -> GDXFile
105+ read_gdx (filepath[, sink] ; parse_integers= true , only= nothing ) -> GDXFile
102106```
103107
108+ - ` sink ` : callable that materializes a column table, defaulting to ` Tables.columntable `
104109- ` parse_integers ` : convert set elements like ` "2020" ` to ` Int `
105110- ` only ` : vector of symbol names to load (e.g. ` [:x, :demand] ` )
106111
107112### Writing
108113
109114``` julia
110- # Write DataFrames as parameters (convenience)
111- write_gdx (filepath, " name" => DataFrame , ... )
115+ # Write tables as parameters (convenience)
116+ write_gdx (filepath, " name" => table , ... )
112117
113118# Write a full GDXFile (sets, parameters, variables, equations)
114119write_gdx (filepath, gdxfile:: GDXFile )
@@ -117,8 +122,8 @@ write_gdx(filepath, gdxfile::GDXFile)
117122### Querying a GDXFile
118123
119124``` julia
120- gdx[:name ] # records DataFrame (bracket access)
121- gdx. name # records DataFrame (property access)
125+ gdx[:name ] # records table (bracket access)
126+ gdx. name # records table (property access)
122127get_symbol (gdx, :name ) # full GDXSymbol object
123128
124129list_sets (gdx) # list set names
0 commit comments