Help me with an ampl error!

i have a problem in the dat file , I cant find the proper code or way to read a table from excel to AMPL. the files are shown below.

project.xlsx (70.5 KB)
sec.mod (393 Bytes)
sec.dat (318 Bytes)

1 Like

Your file

"C: \path\file.project.xlsx"

cannot be found, because there is an extra space in its name. You will need to fix all of the table statements to remove this space, so that the file is specified as

"C:\path\file.project.xlsx"

Also note the following:

  • In sec.dat, you will need to write data; before param B := 10000; — so that AMPL knows you will be reading some data statements. (Otherwise, you will get a “B is already defined” error.)

  • We now recommend using our Direct Spreadsheet Interface — rather than the older “ODBC” interface, which can be much harder to set up.

Hi Fatima,

In addition to what Bob suggested, you can also use the Python API to send data to ampl. This is an example of reading data from a google sheet (you could do the same with an excel’s).

I find Python more suitable to send data to ampl, the api makes it much easier.