How to Get the List of all Files with Size,Modified and Path from GCS Bucket and Load into BigQuery

Topic: How to Get the List of all Files with Size, Modified and Path from GCS Bucket and Load into BigQuery.

In this post, you will learn how to get the list of all files with their size, modified date, and path from a Google Cloud Storage (GCS) bucket and load them into BigQuery.

We will guide you through the process step by step, starting with setting up the necessary permissions and credentials for accessing GCS and BigQuery.

By the end of this video, you will clearly understand how to extract file metadata from a GCS bucket, load it into BigQuery, and leverage its powerful querying capabilities for further analysis.

If you’re a data engineer, data analyst, or anyone working with large datasets in Google Cloud Platform, this post is for you! 

Script: 

function listFolderContents() { var foldername = 'Final Logos'; // provide the name of Folder from which you want to get the list of files var ListOfFiles = 'ListOfFiles_' + foldername; var folders = DriveApp.getFoldersByName(foldername) var folder = folders.next(); var contents = folder.getFiles(); var ss = SpreadsheetApp.create(ListOfFiles); var sheet = ss.getActiveSheet(); sheet.appendRow( ['name', 'link','sizeInMB'] ); var var_file; var var_name; var var_link; var var_size; while(contents.hasNext()) { var_file = contents.next(); var_name = var_file.getName(); var_link = var_file.getUrl(); var_size=var_file.getSize()/1024.0/1024.0; sheet.appendRow( [var_name, var_link,var_size] ); }
};

That’s it! You should now have a BigQuery table with all the files from your GCS bucket along with their size, modified date, and path.

 

Video Demo: How to Get the List of all Files with Size, Modified and Path from GCS Bucket and Load into BigQuery.

4 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Das Schreiben einer Masterarbeit ist eine äußerst anspruchsvolle Aufgabe, insbesondere wenn man die vielfältigen Anforderungen und die umfassende Seitenanzahl berücksichtigt. In solchen Fällen kann es vorteilhaft sein, nach Fachleuten zu suchen, die bei der Erstellung der Masterarbeit helfen können. Eine häufig genutzte Option ist die Beauftragung eines Ghostwriters- meinghostwriter.de/preise/ , der die Arbeit gemäß den individuellen Anforderungen und Wünschen verfasst. Dieser Ansatz ermöglicht es, die Herausforderungen zu bewältigen und ein zufriedenstellendes Ergebnis zu erzielen.

    ReplyDelete
  3. Ich verstehe Ihre Anmerkungen zu den Herausforderungen beim Schreiben einer Masterarbeit, insbesondere angesichts der vielfältigen Anforderungen und des umfangreichen Umfangs. In solchen Fällen kann es vorteilhaft sein, nach Fachleuten zu suchen, die bei der Erstellung der Masterarbeit helfen können. Eine häufig genutzte Option ist die Beauftragung eines Ghostwriters, der die Arbeit gemäß den individuellen Anforderungen und Wünschen verfasst. Dieser Ansatz ermöglicht es, die Herausforderungen zu bewältigen und ein zufriedenstellendes Ergebnis zu erzielen.

    ReplyDelete
  4. FASTEST WAY TO RECOVER YOUR STOLEN BITCOIN/USDT 2024

    I cannot thank ethicsrefinance enough for their incredible work in helping me recover my stolen $325,000 USDT. I was devastated when I realized my funds had been stolen, but ethicsrefinance stepped in and used their expertise to retrieve my money. Their professionalism and dedication to their work was evident throughout the entire process. They kept me updated and informed every step of the way, and I felt confident and reassured knowing that my case was in their hands. Thanks to ethicsrefinance, I was able to recover my funds and regain my financial stability. I highly recommend their services to anyone in need of ethical and reliable hacking assistance. Thank you, ethicsrefinance, for your exceptional work and for giving me peace of mind. Reach out to EthicsRefinance hackers today and reclaim what is rightfully yours

    EMAIL VIA: ethicsrefinance @ gmail .com

    TELEGRAM: @ethicsrefinance

    ReplyDelete