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

427
Views
Escriba y recupere un archivo JSON en Google Drive usando Google Apps Script

Estoy escribiendo un programa que toma los datos de una gran hoja de cálculo de Google, los trata y los manipula y los conecta con otras hojas en el mismo archivo. Para mejorar mi tiempo de ejecución y hacer una base de datos de respaldo.

Me gustaría almacenar los datos en un archivo JSON en algún lugar que pueda usar fácilmente en el script de Google Apps nuevamente (creo que Google Drive es la mejor opción gratuita). ¿Cómo logro esto?

Le agradecería que pudiera mostrar los códigos exactos que guardan el siguiente archivo en Google Drive y luego lo vuelven a leer en el script.

 let listA = [{id: 34, performance: 200, supervisor: 'A', name: 'Aethelwich'}, {id: 35, performance: 300, supervisor: 'B', name: 'Aethelram'}, {id: 36, performance: 400, supervisor: 'A', name: 'Aethelham'}, {id: 41, performance: 500, supervisor: 'A', name: 'Aethelfred'}]; let jsonObject = JSON.stringify(listA); // 1. code to save this jsonObject to Google Drive // 2. code to retrieve the same saved JSON file back from google drive
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Para lograr su objetivo, ¿qué le parece el siguiente script de muestra?

Guión de muestra:

 let listA = [{ id: 34, performance: 200, supervisor: 'A', name: 'Aethelwich' }, { id: 35, performance: 300, supervisor: 'B', name: 'Aethelram' }, { id: 36, performance: 400, supervisor: 'A', name: 'Aethelham' }, { id: 41, performance: 500, supervisor: 'A', name: 'Aethelfred' }]; let jsonObject = JSON.stringify(listA); // Save the data as a file. const file = DriveApp.createFile("sample.txt", jsonObject); // Or, if you want to put the file to the specific folder, please use DriveApp.getFolderById("folderID").createFile("sample.txt", jsonObject) const fileId = file.getId(); console.log(fileId) // Retrieve the data from the file. const text = DriveApp.getFileById(fileId).getBlob().getDataAsString(); // please set the file ID of the saved file. const array = JSON.parse(text); console.log(array)

Referencias:

  • createFile(nombre, contenido)
  • getFileById(id)
  • getDataAsString()
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!