4
$\begingroup$

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

Any bright idea?

$\endgroup$

1 Answer 1

4
$\begingroup$

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.

$\endgroup$
4
  • $\begingroup$ Thanks for replay, I didn't get it! how to save variable !? I have a matrix to save $\endgroup$
    – mj.beyrami
    Nov 19, 2018 at 10:56
  • $\begingroup$ 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. $\endgroup$ Nov 19, 2018 at 11:05
  • $\begingroup$ 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. $\endgroup$
    – mj.beyrami
    Nov 19, 2018 at 11:14
  • $\begingroup$ 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. $\endgroup$ Nov 19, 2018 at 11:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.