vinci1it2000 / formulas

Excel formulas interpreter in Python.
https://formulas.readthedocs.io/
European Union Public License 1.1
342 stars 75 forks source link

Allow the first parameter to be empty in a function call. #139

Closed travpow closed 2 days ago

travpow commented 3 months ago

Status

READY

Description

Emit a separator token if the previous token is a separator, (i.e., we are making an empty statement) or if the previous token was the start of a parenthetical group (i.e., the first parameter is empty).

The use case here is primarily to support third party APIs with optional first parameters. For instance, a =GETDATA(<ids>, <filter>) API could allow a user to leave out the parameter and just apply a filter to the entire dataset. This may look like =GETDATA(,"Country = 'US'")

Steps to Test or Reproduce

Added two new test cases ('=FIRSTPARAMEMPTY(,,1)', 'FIRSTPARAMEMPTY(,,1)'),

As in Excel, we'll treat the first empty param as Falsy. ('A1', '=IF(,FALSE,"PASS")', {}, '<Ranges>(A1)=[[\'PASS\']]'),

vinci1it2000 commented 2 days ago

@travpow, great work! It has been implemented in development and will be available in the next release.