Ask Your Question

Save data to text file - List_plot(...).save(Path, Name..)?

asked 2012-06-24 21:42:16 -0500

anonymous user



Is there a way to save data in list plot as a text file in stead/ in addition to showing it with .show() ?

In this way - I want to export the data from my list, say to Excel or Matlab in order to plot it using their tools. I wish the data would be arrange in the text file in a list of values that I could then copy (for example) to the Excel table.

Thanking u on advance!

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted

answered 2012-06-25 00:34:46 -0500

ndomes gravatar image

You can use the Data Menue

DATA is an environment variable: path to the attached files of the respective worksheet.

L = [0..10]
out = file(DATA+'mydata.txt','w')
for k in L:

The files should appear in the list of Data files.

edit flag offensive delete link more


O.K, thanks! - Where do I see the list of data files, and are they in a format that I could export to other program, such as an Excel table, or as a *.png? What is the meaning of the two different 'out's - before and inside the loop? The out.close() is used because of the loop?

Erez gravatar imageErez ( 2012-06-25 01:16:46 -0500 )edit

answered 2012-06-25 09:05:43 -0500

calc314 gravatar image

updated 2012-06-25 09:08:16 -0500

Another option is the use the csv package in python. You can write using this as follows. In the snippet below, info is a list of lists containing data that you want to write to a file.

import csv
writefile = csv.writer(open(DATA+'myfile.csv', 'w'))
for i in range(0,len(info)): 

This will result in a .csv file that Excel can read.

edit flag offensive delete link more

answered 2012-06-26 23:18:05 -0500

Erez gravatar image

Thx both! Eventually I tried more or less both ways and it worked, I used the txt file.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2012-06-24 21:42:16 -0500

Seen: 2,471 times

Last updated: Jun 26 '12