A user wanted to read spreadsheet change.xlsx using these statements:
set Family;
set Unit;
param Change {Family, Family, Unit};
table Family IN "amplxl" "change.xlsx": [Family] IN;
read table Family;
table Unit IN "amplxl" "change.xlsx": [Unit] IN;
read table Unit;
table Change IN "amplxl" "change.xlsx": [Fam1, Fam2, Unit], Change;
read table Change;
But read table Change; gave this error:
Error reading table Change with table handler amplxl:
Could not find column Change in spreadsheet table header
The error occurs because the column heading Change has a trailing space. There are several ways we could consider dealing with this hard-to-spot error:
- Remove trailing spaces from headers.
- Include the trailing space in the error message (so that there would be two spaces after
column Change in the above example).
- Modify the error message so that the trailing space is more obvious, for example by putting quotes around the column name (so that it would be
column "Change " in the above example).
There's a similar issue with trailing spaces in non-numeric data. Typically they do not prevent the spreadsheet data from being read, but lead to an error like invalid subscript Change[1,1,'A '] discarded at some later point.
A user wanted to read spreadsheet change.xlsx using these statements:
But
read table Change;gave this error:The error occurs because the column heading
Changehas a trailing space. There are several ways we could consider dealing with this hard-to-spot error:column Changein the above example).column "Change "in the above example).There's a similar issue with trailing spaces in non-numeric data. Typically they do not prevent the spreadsheet data from being read, but lead to an error like
invalid subscript Change[1,1,'A '] discardedat some later point.