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

121
Views
¿Cómo optimizar esta función para conjuntos de datos grandes (100k filas y 10 columnas) usando Google Apps Script?

Esta función funciona bien, pero hasta 20k filas. ¿Qué podría cambiar para que funcione rápido?

 const SOURCE_FILE_ID = 'ID'; function getData() { const sourceSheet = SpreadsheetApp.openById(SOURCE_FILE_ID); const sourceRng = sourceSheet.getSheetByName('ativcopiar').getRange(1, 1, sourceSheet.getLastRow(), 9); const sourceValues = sourceRng.getValues(); var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheetByName('Ativ.'); var destinationRng = sheet.getRange(1, 1, sheet.getLastRow(), 9); destinationRng.clearContent(); destinationRng.setValues(sourceValues); }

A veces, se excede el límite de tiempo.

¡Aprecia cualquier luz! Gracias.

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

0

Creo que su objetivo es el siguiente.

  • Desea reducir el costo del proceso de su script.

En este caso, ¿qué tal si usamos Sheets API? Cuando se usa Sheets API, el costo del proceso se puede reducir un poco. Ref Cuando se usa Sheets API para su secuencia de comandos, se convierte en lo siguiente.

Guión modificado:

Antes de usar este script, habilite Sheets API en los servicios avanzados de Google .

 function myFunction() { const SOURCE_FILE_ID = '###'; const sheet = SpreadsheetApp.openById(SOURCE_FILE_ID).getSheetByName('ativcopiar'); const dstSS = SpreadsheetApp.getActiveSpreadsheet(); var dstSheet = dstSS.getSheetByName('Ativ.'); var destinationRng = dstSheet.getRange(1, 1, dstSheet.getLastRow(), 9); destinationRng.clearContent(); SpreadsheetApp.flush(); const values = Sheets.Spreadsheets.Values.get(dstSS.getId(), "'ativcopiar'!A1:I" + sheet.getLastRow()).values; Sheets.Spreadsheets.Values.update({values}, dstSS.getId(), "Ativ.", {valueInputOption: "USER_ENTERED"}); }

Referencias:

  • Benchmark: lectura y escritura de hojas de cálculo usando Google Apps Script
  • Método: hojas de cálculo.valores.get
  • Método: hojas de cálculo.valores.actualización
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!