Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
assert the length of columns in google sheets

The below code filters google spreadsheet based on the boolean expression below. Code thanks to https://stackoverflow.com/users/19043534/newaza

function DeleteEmptyRows() {

  const sheet = SpreadsheetApp.getActiveSheet()
  const values = sheet.getDataRange()
                      .getValues()
                      .filter(row => row[9] !== '' && row[7] !== '' && row[6] !== '')

  sheet.getDataRange().clearContent()

  return sheet.getRange(1, 1, values.length, values[0].length)
              .setValues(values)                      

}

Nevertheless, I am having an issue that some records are being deleted even not matching the boolean expression. Is there a way to assert that the lengths of row[9] row[6] and row[7] in the sheet before and after filter-operation ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

so The Error was caused by the boolean expression! Nevertheless, @Tanaike suggestion helps to debug column length.

  function delDups() {

    const sheet = SpreadsheetApp.getActiveSheet();
    const orgValues = sheet.getDataRange().getValues();
    console.log(orgValues.length);
    const values = orgValues.filter(row => !(!row[7] && !row[6]));
  
    sheet.getDataRange().clearContent();
    console.log(values.length);
    return sheet.getRange(1, 1, values.length, values[0].length)
                .setValues(values);                  
  
  }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!