List Archives > 
Maple User Group List Archive > 
Archive by date > 
This Month By Date > 
This Month By Topic
[MUG] Reading the Date from a txt File
| [MUG] Reading the Date from a txt File |
|
Author: Juan Navarro
Posted: Fri, 3 May 2002 10:40:30 -0500
|
>> From: Juan Navarro "Juan.Navarro"
I have to plot the data from a text file that contains pairs of data in the
form of [date, value]. I can read the file with
my_data:= readdata (filename, [string, float]);
but I can't plot the data.
I don't know how to process the date in Maple to plot the function. Can
somebody help?.
Thanks.
Juan Navarro-Sorroche
|
| [MUG] Re: Reading the Date from a txt File |
|
Author: Maple User Group
Posted: Fri, 10 May 2002 16:58:21 -0400
|
>> From: Maple User Group "maple_gr"
On Fri, 3 May 2002, Juan Navarro wrote:
> I have to plot the data from a text file that contains pairs of data in the
> form of [date, value]. I can read the file with
> my_data:= readdata (filename, [string, float]);
> but I can't plot the data.
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Thu, 9 May 2002 16:05:49 -0700 (PDT)
From: Robert Israel "israel"
To: "''" "maple-list"
Subject: Reading the Date from a txt File
You didn't say what format your dates are in. Whatever format it is,
fscanf or sscanf should be able to extract the month, day and year.
Then it's just a question of converting those to an integer. For example,
if all dates are between 1 Mar 1900 and 28 Feb 2100 and you take 1 Jan
2000 as day 1, you could use
> M:= [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
> f:= (month, day, year) -> (year-2000)*365+floor((year-1997)/4)+
M[month]+day + `if`(year mod 4 = 0 and month > 2, 1, 0);
Robert Israel "israel"
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia
Vancouver, BC, Canada V6T 1Z2
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
From: Stanley J Houghton "S.J.Houghton"
Date: Thu, 9 May 2002 09:01:01 +0100
To: "Juan.Navarro" "maple-list"
Subject: Reading the Date from a txt File
You need to convert your dates, which are currently strings, to
numbers. This depends of course on your date format. One way to do
it is to write a convertion proc using the string manipulation and test
routines contained in the StringTools package (see help pages).
Stan
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
From: "Otto C. Wilke, PhD, MATH" "owilke"
To: "maple-list"
Date: Thu, 9 May 2002 10:15:56 CST6CDT
Subject: Reading the Date from a txt File
Juan,
If someone can convert the date to a number, then you can plot as
follows. Given the text file containing
[1998,425],[1999,389],[2000,353],[2001,275],[2002,220]
Try the following
restart;f:= fopen( "C:\\My Documents\\My
Documents\\net1314\\testfile.txt" , READ, TEXT);
f := 0
> readdata(f,string);
["[1998,425],[1999,389],[2000,353],[2001,275],[2002,220]"]
> op(1,%);
"[1998,425],[1999,389],[2000,353],[2001,275],[2002,220]"
> str1:="["||%||"]";
str1 := "[[1998,425],[1999,389],[2000,353],[2001,275],[2002,220]]"
> list1:=parse(%);
list1 := [[1998, 425], [1999, 389], [2000, 353], [2001, 275],
[2002, 220]]
> p1:=plot(%,style=point,symbol=cross,symbolsize=30):
> with(plots):display({p1},labels=[Year,Summer_Enrollment]);
There is surely a more elegant way to do this.
Otto Wilke
|
Previous by date: [MUG] declaration of procedure-type, Stefano Sofia
Next by date: [MUG] plot after assume, Matthias Kawski
Previous thread: [MUG] PostScript Bug in Maple 6.02a Win 2k Pro, Jeff Wright
Next thread: [MUG] plot after assume, Matthias Kawski
|