4

I want to save variables and outputs in text file with colab!

Any bright idea?

mj.beyrami
  • 41
  • 1
  • 1
  • 2

1 Answers1

4

Save your content in the current directory and execute !dir to see the content. Then follow the following code snippet:

from google.colab import files
files.download('your typical text file or what ever.txt')

For more information take a look at here.

Green Falcon
  • 13,868
  • 9
  • 55
  • 98
  • Thanks for replay, I didn't get it! how to save variable !? I have a matrix to save – mj.beyrami Nov 19 '18 at 10:56
  • I guess your question is irrelevant to the colab. You have a question about numpy arrays I guess. You can use `np.save` and `np.loadtxt` for storing and loading numpy matrices. – Green Falcon Nov 19 '18 at 11:05
  • I'm new in python. All I want is just save some of my code's variables in text file, which they are mostly 2*2. – mj.beyrami Nov 19 '18 at 11:14
  • If they are numpy arrays use np.savetxt. If they are list, try to create numpy arrays and then save them. For doing so, use `np.array`. – Green Falcon Nov 19 '18 at 11:22