Subject: Read data file containing fractional numbers?
From: Richard Fateman
Date: Thu, 19 May 2011 15:05:34 -0700
Didn't I just answer this? :)
Do a little editing on the data file. There are many many editors, and
some of them can do this with a few keystrokes.
Here you can do this, starting with the comma-separated file..
replace newline with ],[
put data: [[
at the beginning
delete extra ,[
at the end.
If the data was produced by a program, you could of course have it do
this extra stuff too.
RJF
On 5/19/2011 2:58 PM, Edwin Woollett wrote:
> Given a text data file with either
> space or comma separated items which
> may include signed fractional numbers,
> such as:
>
> 1 0
> 2 -1/3
> 3 -1/2
> 4 -3/5
> 5 -2/3
>
> or
>
> 1, 0
> 2, -1/3
> 3, -1/2
> 4, -3/5
> 5, -2/3
>
> how can I use Maxima to read this data into a nested
> list of the form
> [ [1,0], [2,-1/3], [3, -1/2], [4, -3/5], [5, -2/3] ] .
>
> My attempts with read_nested_list result in things
> like
>
> (%i22) fdataL : read_nested_list ("mydata2.dat",comma);
> (%o22) [[1, 0], [2, [- 1, /, 3]], [3, [- 1, /, 2]], [4, [- 3, /, 5]],
> [5, [-
> 2, /, 3]]]
>
> Ted Woollett
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima