Where are saved files in Google Colab located?

16,601

Solution 1

On the left side of colab interface, there is a "Files" tab. You can find all the files you saved there.

Solution 2

Complementing @jules-cui answer, on the left side of the Colab interface you will see a few icons. Click on the folder icon, which opens all the files in your runtime. You can click on any of the files' extended menu to the right, and click Download.

Solution 3

If you mounted GDrive then files should be stored in the folder named Colab Notebooks

You could also check your current folder with one of the commands below.

%cd

or

!pwd 
Share:
16,601

Related videos on Youtube

Mo Houshmand
Author by

Mo Houshmand

Updated on June 04, 2022

Comments

  • Mo Houshmand
    Mo Houshmand almost 2 years

    I'm trying to access a VTK file where the solution to the heat equation is saved, but I've no idea where it's saved in Colab.

    from fenics import *
    import time
    T = 2.0            # final time
    num_steps = 50     # number of time steps
    dt = T / num_steps # time step size
    # Create mesh and define function space
    nx = ny = 30
    mesh = RectangleMesh(Point(-2, -2), Point(2, 2), nx, ny)
    V = FunctionSpace(mesh, 'P', 1)
    # Define boundary condition
    def boundary(x, on_boundary):
        return on_boundary
    bc = DirichletBC(V, Constant(0), boundary)
    # Define initial value
    u_0 = Expression('exp(-a*pow(x[0], 2) - a*pow(x[1], 2))',
                     degree=2, a=5)
    u_n = interpolate(u_0, V)
    # Define variational problem
    u = TrialFunction(V)
    v = TestFunction(V)
    f = Constant(0)
    F = u*v*dx + dt*dot(grad(u), grad(v))*dx - (u_n + dt*f)*v*dx
    a, L = lhs(F), rhs(F)
    # Create VTK file for saving solution
    vtkfile = File('heat_gaussian/solution.pvd')
    # Time-stepping
    u = Function(V)
    t=0
    for n in range(num_steps):
        # Update current time
        t += dt
        # Compute solution
        solve(a == L, u, bc)
        # Save to file and plot solution
        vtkfile << (u, t)
        plot(u)
        # Update previous solution
        u_n.assign(u)
    # Hold plot
    #interactive()
    

    I've tried;

    from google.colab import files
    plt.savefig("vtkfile")
    files.download("vtkfile")
    

    And

    from google.colab import files files.upload()
    from google.colab import drive drive.mount('vtkfile')
    

    But still getting errors. Where are files created in the notebook stored?

  • Mo Houshmand
    Mo Houshmand over 4 years
    Both %cd and !pwd gives /root as output. I've found the files but how do I download them?
  • Dkoded
    Dkoded about 3 years
    exactly what my eyes failed to catch :D Thanks!