0

Read a file from S3 within a script (Python)

by
Published Mar 12, 2024

Details on S3 integration at https://www.windmill.dev/docs/core_concepts/persistent_storage/large_data_files

Script s3
  • Submitted by henri186 Python3
    Created 834 days ago
    1
    #requirements:
    2
    wmill>=1.251.7
    3
    
    
    4
    #Details on S3 integration at https://www.windmill.dev/docs/core_concepts/persistent_storage/large_data_files
    5
    
    
    6
    import wmill
    7
    from wmill import S3Object
    8
    
    
    9
    def main(input_file: S3Object):
    10
        # Load the entire file_content as a bytes array
    11
        file_content = wmill.load_s3_file(input_file)
    12
        print(file_content.decode('utf-8'))
    13
    
    
    14
        # Or load the file lazily as a Buffered reader:
    15
        with wmill.load_s3_file_reader(input_file) as file_reader:
    16
            print(file_reader.read())