How do I import raw data like:
1 "4072 400" 0 0 2 1.0280 -10.70 2000.000 500.0000 1332.970 406.026 400.000 1.0280 1000.00 -300.00 0.00000 0.00000 0 2 "4071 400" 0 0 2 1.0330 -5.241 300.0000 100.0000 469.9895 86.6269 400.000 1.0330 250.000 -50.000 0.00000 -4.0000 0 3 "4011 400" 0 0 3 1.0500 0.0000 0.000000 0.000000 437.3903 -93.741 400.000 1.0500 500.000 -100.00 0.00000 0.00000 0 4 "4012 400" 0 0 2 1.0400 2.4097 0.000000 0.000000 600.5866 -134.52 400.000 1.0400 400.000 -160.00 0.00000 -1.0000 0 5 "4021 400" 0 0 2 1.1000 -22.22 0.000000 0.000000 281.9937 -30.000 400.000 1.1000 150.000 -30.000 0.00000 0.00000 0 ...
It is not that difficult as the set elements with the blanks are quoted. Just introduce column names and import the data into GAMS using $onDelim
and $offDelim
:
Table x(*,*,*) $onDelim a,b,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 1 "4072 400" 0 0 2 1.0280 -10.70 2000.000 500.0000 1332.970 406.026 400.000 1.0280 1000.00 -300.00 0.00000 0.00000 0 2 "4071 400" 0 0 2 1.0330 -5.241 300.0000 100.0000 469.9895 86.6269 400.000 1.0330 250.000 -50.000 0.00000 -4.0000 0 3 "4011 400" 0 0 3 1.0500 0.0000 0.000000 0.000000 437.3903 -93.741 400.000 1.0500 500.000 -100.00 0.00000 0.00000 0 4 "4012 400" 0 0 2 1.0400 2.4097 0.000000 0.000000 600.5866 -134.52 400.000 1.0400 400.000 -160.00 0.00000 -1.0000 0 5 "4021 400" 0 0 2 1.1000 -22.22 0.000000 0.000000 281.9937 -30.000 400.000 1.1000 150.000 -30.000 0.00000 0.00000 0 ... ; display x;
and you will get:
---- 46 PARAMETER x 3 4 5 6 7 8 9 10 11 1 .4072 400 2.000 1.028 -10.700 2000.000 500.000 1332.970 406.026 400.000 1.028 2 .4071 400 2.000 1.033 -5.241 300.000 100.000 469.990 86.627 400.000 1.033 3 .4011 400 3.000 1.050 437.390 -93.741 400.000 1.050 4 .4012 400 2.000 1.040 2.410 600.587 -134.520 400.000 1.040 5 .4021 400 2.000 1.100 -22.220 281.994 -30.000 400.000 1.100