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

Numeric values are not numeric #21

Open
skibulk opened this issue Feb 9, 2024 · 0 comments
Open

Numeric values are not numeric #21

skibulk opened this issue Feb 9, 2024 · 0 comments

Comments

@skibulk
Copy link

skibulk commented Feb 9, 2024

Numbers such as prices.usd and edhrec_rank should be type cast to numbers. Failure to do so breaks a couple things in Google Sheets:

  1. "Number" formatting won't be applied, including the dollar sign and commas.
  2. Functions which compare numbers won't work, such as GTE (greater than or equal).

There are similar problems with empty strings, Booleans, and dates.

To fix this, I recommend replacing lines 90 and 91 as follows:

      if (typeof val === "string") {
        if(val == "") {
          val = null;
        } else if(val == "TRUE"){
          val = true;
        } else if(val == "FALSE"){
          val = false;
        } else if(!isNaN(val) && !isNaN(parseFloat(val))){
          val = +val;
        } else {
          let d = val.match(/^\d{4}-\d{2}-\d{2}$/);
          if(d) {
            val = new Date(val);
          } else {
            // add extra line breaks for readability
            val = val.replace(/\n/g, "\n\n");
          }
        }
      }
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