Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing spaces cause hard-to-spot errors #17

Open
4er4er4er opened this issue Jan 5, 2021 · 0 comments
Open

Trailing spaces cause hard-to-spot errors #17

4er4er4er opened this issue Jan 5, 2021 · 0 comments

Comments

@4er4er4er
Copy link

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.

@4er4er4er 4er4er4er changed the title Trailing spaces are significant Trailing spaces cause hard-to-spot errors Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant