You are currently viewing the new Anvil Editor Docs.
Switch to the Classic Editor Docs
You are currently viewing the Classic Editor Docs.
Switch to the new Anvil Editor Docs

anvil.files Module



Context manager for editing data files.

Instance Methods

__enter__() → string

Begin editing the file.


End editing the file, uploading its new contents.


Create a new ‘Files’ object



Instance Methods

__getitem__() → string

Return the path of a file

editing(path) → anvil.files.EditingContextManager instance

Edit a file. To ensure the proper acquisition and release of the file, use the editing`` function in a withstatement e.g.with data_files.editing(’test.txt’) as file:`

    open(path, [mode="r"]) → anvil.files.OpenContextManager instance

    The open() function opens the file (if possible) and returns the corresponding file object.


      Context manager for opening data files.

      Instance Methods

      __enter__() → File object

      Open the file.


      Close the file, uploading its contents if it was opened for writing or appending.



      Access Data Files from the Data Files Service. To access a file stored in the Data Files Service use square brackets containing the path of the desired file - data_files['<file_path>'].

      Do you still have questions?

      Our Community Forum is full of helpful information and Anvil experts.