Ask Your Question

reddwarf2956's profile - activity

2013-11-18 14:29:04 +0200 received badge  Famous Question (source)
2013-04-23 18:20:55 +0200 received badge  Notable Question (source)
2013-04-20 16:20:40 +0200 received badge  Notable Question (source)
2013-02-10 10:27:51 +0200 received badge  Popular Question (source)
2012-12-11 08:28:59 +0200 received badge  Popular Question (source)
2012-08-18 23:21:23 +0200 marked best answer reading, computing, writing

Sage builds on top of Python which provides pretty much any general purpose programming functionality. There are plenty of good tutorials on reading / writing data using Python, but you might find this one useful:

http://www.ibm.com/developerworks/opensource/library/os-python8/

2012-08-18 23:21:18 +0200 marked best answer reading, computing, writing

Here is one collection of some simple python code.

To read a data file, the file is stored with the Sage notebook in a directory labelled DATA by Sage.

import csv
data =list( csv.reader(open(DATA+'infile.csv','rU')) )

The data is then in a list that you can manipulate.

Some code for writing a list named info that contains lists is:

writefile = csv.writer(open(DATA+'outfile.csv', 'w'))
for i in range(0,len(info)): 
      writefile.writerow(info[i])
2012-08-18 23:21:18 +0200 received badge  Scholar (source)
2012-08-16 14:48:28 +0200 received badge  Supporter (source)
2012-08-16 14:43:16 +0200 received badge  Organizer (source)
2012-08-13 17:43:11 +0200 commented answer reading, computing, writing

Oh, yea. My data file is just a text file. I see you have the .csv extension does this matter on how the file is read or is a .csv file text (I know that I can use a different file name)?

2012-08-13 17:31:52 +0200 commented answer reading, computing, writing

I found information with prime_pi. It was not primepi. I see that you stated that the data file 'infile.csv' is "stored with the Sage notebook in a directory labelled DATA by Sage". Can it be placed elsewhere?

2012-08-13 17:25:38 +0200 commented answer reading, computing, writing

So is this reading/writing one row at a time? or the whole file? I realize that the manipulation is done different depending on which method is used. I think each of the sequences made will be written in a seperate file. So, I am not expecting any overwrite issues.

2012-08-13 01:52:32 +0200 asked a question reading, computing, writing

OK, I just installed Sage for the first time and now I would like to figure out how to read and write a file as well as run 'functions' like primepi (count of prime numbers).

Axxxxxx is a sequence in the OEIS at oeis.org.

The data file has two columns "n, A104272(n)" with n > 3*10^6:

1 2 2 11 3 17 4 29 5 41 ... ...

After reading the data I need it take the difference of the A182873(n) = A104272(n+1) - A104272(n), find primepi(A104272(n+1)) and primepi(A104272(n)) and the difference of those two A190874(n) = primepi(A104272(n+1)) - primepi(A104272(n)). After that I would like to write the data back to a file.

I have been looking at the tutorial, but I have not found the section on reading data or anything like it.

2012-08-12 14:18:21 +0200 commented question Installing on Ubuntu 12.04: Seeding
2012-08-11 10:49:15 +0200 commented question Installing on Ubuntu 12.04: Seeding

Still going:Download Progress Summary as of Sat Aug 11 08:47:24 2012 [#3 SEEDING(ratio:0.0) CN:0 SEED:0] FILE: /home/owner/sage-5.2-linux-64bit-ubuntu_12.04_lts-x86_64-Linux.tar.lzma [#3 SEEDING(ratio:0.0) CN:0 SEED:0]

2012-08-10 22:54:21 +0200 received badge  Editor (source)
2012-08-10 21:26:51 +0200 asked a question Installing on Ubuntu 12.04: Seeding

I am using the metalink at http://mirrors.xmission.com/sage/linu... for sage-5.2-linux-64bit-ubuntu_12.04_lts-x86_64-Linux.tar.lzma The first hour seemed to be downloads and installs. The last 3 hours was commented by the following every minute: (Is it locked up?)

* Download Progress Summary as of Fri Aug 10 19:21:25 2012 *

[#3 SEEDING(ratio:0.0) CN:0 SEED:0] FILE: /home/owner/sage-5.2-linux-64bit-ubuntu_12.04_lts-x86_64-Linux.tar.lzma

* Download Progress Summary as of Fri Aug 10 19:22:25 2012 *

[#3 SEEDING(ratio:0.0) CN:0 SEED:0] FILE: /home/owner/sage-5.2-linux-64bit-ubuntu_12.04_lts-x86_64-Linux.tar.lzma

[#3 SEEDING(ratio:0.0) CN:0 SEED:0]