Hi Jackson
When you want to read one column you have probably a parameter defined over a set. Something like m(year) and then want to fill this parameter with the data from the excel sheet.
So, you should have two columns: one with the set over which you defined the parameter m and one with the values. You then can just read all the values with
your command but the range A2:B1014.
Cheers
Renger
From: gams...@googlegroups.com [mailto:gams...@googlegroups.com]
On Behalf Of Jackson
Sent: Tuesday, July 03, 2012 2:50 PM
To: gams...@googlegroups.com
Subject: Reading data from Excel, but only one column?
Hello everyone!
I just started using GAMS today and I am trying to figure out how to input Excel data into GAMS. I've gone over some of the GDXXRW example files in the User Guide but I can't seem to figure out how to only read one whole column from an Excel sheet. I keep getting a "bad data range for symbol m" error.
Here is my code:
Sets
i SKU /1*1013/
* Reading Margin data
$CALL GDXXRW.EXE skudata.xls par=m rng=sheet!B2:B1014 Cdim=0 Rdim=1
Parameters m(i) Margin;
$GDXIN skudata.gdx
$LOAD m
$GDXIN
And this is the error I get:
--- call GDXXRW.EXE skudata.xls par=m rng=sheet!B2:B1014 Cdim=0 Rdim=1
GDXXRW Mar 17, 2012 23.8.2 WIN 31442.32372 VS8 x86/MS Windows
Input file : C:\Users\jachou\Documents\gamsdir\projdir\skudata.xls
Output file: C:\Users\jachou\Documents\gamsdir\projdir\skudata.gdx
**** Bad data range for symbol m : sheet!B2:B1014
Output gdx file deleted
Any help or advice would be greatly appreciated. Thanks!
--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/gamsworld/-/6z9qhs7vJLAJ.
To post to this group, send email to
gams...@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.
Keep CDIM=0 and start your range just below your column title, then you don’t need the set a.
Renger
From: gams...@googlegroups.com [mailto:gams...@googlegroups.com]
On Behalf Of Jackson
Sent: Tuesday, July 03, 2012 4:04 PM
To: gams...@googlegroups.com
Subject: Re: Reading data from Excel, but only one column?
Hello Renger,
Thanks for the advice. I actually figured out that I needed a set label column to match each element for the margin parameter.
However, I'm not sure if I'm doing this correctly. I ended up creating a dummy set:
Sets
i SKU number /1*1013/
a Column entry /Margin/;
* Reading Margin data
$CALL GDXXRW.EXE skudata.xls par=m rng=margin!A1:B1014 Rdim=1 Cdim=1
Parameters m(i,a) Margin;
$GDXIN skudata.gdx
$LOAD m
$GDXIN
display m;
This code works and matches up with the set i. But is there a way where I can simply have one set? I don't want to be creating new dummy sets for each column of data.
Thanks,
Jackson
To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/GtWpqwMfCusJ.
Just define two parameters and read them with two calls of gdxxrw:
$CALL GDXXRW.EXE skudata.xls par=m rng=margin!A1:B1014 Rdim=1 Cdim=0
$CALL GDXXRW.EXE skudata.xls par=n rng=margin!C1:D1014 Rdim=1 Cdim=0
Or define a set for the column names and define one parameter with two dimensions ( m(I, columnamesset)) and delete the set column between the two value columns and read the parameter with
$CALL GDXXRW.EXE skudata.xls par=m rng=margin!A1:C1014 Rdim=1 Cdim=1
Cheers
Renger
From: gams...@googlegroups.com [mailto:gams...@googlegroups.com]
On Behalf Of Jackson
Sent: Tuesday, July 03, 2012 4:55 PM
To: gams...@googlegroups.com
Subject: Re: Reading data from Excel, but only one column?
Hello Renger,
I seem to have a different problem now. How would I go about reading multiple columns with one set column?
Column 1 |
Column 2 |
||
1 |
9661.98 |
1 |
19484.58471 |
2 |
61695.89 |
2 |
24140.97804 |
3 |
1284.61 |
3 |
6188.350606 |
4 |
20969.93 |
4 |
13397.07451 |
5 |
14374.08 |
5 |
13668.80667 |
I tried to add another set label column and used the cell ranges C1:D6, but it will only give me an empty parameter set.
Here's my code:
Sets
i SKU number /1*1013/;
* Reading Margin data
$CALL GDXXRW.EXE skudata.xls par=m rng=margin!A1:B1014 Rdim=1 Cdim=0
Parameters m(i) Margin;
$GDXIN skudata.gdx
$LOAD m
$GDXIN
display m;
* Reading Column 2 data
$CALL GDXXRW.EXE skudata.xls par=c rng=margin!C1:D1014 Rdim=1 Cdim=0
Parameters c(i) Column 2;
$GDXIN skudata.gdx
$LOAD c
$GDXIN
display c;
Thanks,
Jackson
To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/YUo-0iReUE8J.
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.
Hi Jyotsna
You are importing ACROPYL twice, once with the direct command “par=ACROPYL” and then using the command “Index=…”. If you delete “par=ACROPYL” and it works fine.
Cheers
Renger
Hi
For that I would need the code or an example that produces the problem.
Send the code and error message, otherwise I have no idea what is going wrong.
Renger
This works fine for me. (You better have a closer look at the manual and if you produce errors, tell us what they are…Not, “I have errors”.)
$call gdxmerge capitalq.gdx laborq.gdx cropq.gdx
parameter acropyl
$gdxin merged.gdx
$LOAD acropyl
display acropyl;
...<p clas
Hi Miner
You can’t read this using the command twice. What happens is that gdxxrw overwrites the rawdata.gdx.
You have to this in one line
$CALL GDXXRW.EXE rawdata.xlsx par=Ta rng=AT!A2:B100 Rdim=1 Cdim=0 par=thetaA rng=thetaA!A2:B100 Rdim=1 Cdim=0
Or use a text file with the instructions line by line or put the instructions for gdxxrw in the excel file (I usually do that). See the manual for some examples.
Cheers
Renger
--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
gamsworld+...@googlegroups.com.
To post to this group, send email to
gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "gamsworld" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gamsworld/3iB2ciTd1Lo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gamsworld+...@googlegroups.com.