"Id","subId","num","n"
63000000000000,63000000000000,63,486730
63000000000000,63000000000001,63,34633
63000000000000,63000000000002,63,15685
63000000000000,63000000000003,63,5815
63000000000000,63000000000004,63,2444
there are certain line of the data with no number between the
commas,like
63000000000000,,64,2444
Now how to read this file to get the contents into arrays?
Thanks
--
Don't forget your dreamS
Skip Knoble
program testcsv
integer :: dat1(2)
real :: dat2(2)
character(len=8) header(4)
open(unit=50,file="Nye.csv")
read(50,*) header
print *, header
do I=1,5
dat2=0 ! Missing data value.
dat1=0 ! Missing data value.
read(50,*) dat2,dat1
print *, dat2,dat1
end do
close(unit=50)
end program testcsv
Input file, Nye.csv follows:
"Id","subId","num","n"
61000000000000,62.,63,486730
61000000000000,62.,,4633
61000000000000,62.,63,15685
61000000000000,62.,63,5815
61000000000000,62.,63,2444
On Wed, 28 Mar 2007 21:55:17 +0800, Nye <zuy...@gmail.com> wrote:
-|
-|Hi, the data file is like:
-|
-|"Id","subId","num","n"
-|63000000000000,63000000000000,63,486730
-|63000000000000,63000000000001,63,34633
-|63000000000000,63000000000002,63,15685
-|63000000000000,63000000000003,63,5815
-|63000000000000,63000000000004,63,2444
-|
-|there are certain line of the data with no number between the
-|commas,like
-|
-|63000000000000,,64,2444
-|
-|Now how to read this file to get the contents into arrays?
-|
-|Thanks
The OP did say Fortran 77. Maybe a Fortran 77 compiler will accept the
code if
(1) it is indented to start in column 7
(2) "::" is removed from the declaration.
(3) "end program testcsv" is replaced by "end"
I am rusty with F77, so the advice above may be incorrect. My general
advice is to use Fortran 95.
Thanks very much, Knoble, it works quite well. :)
Cheers
Nye
--
On 28 Mar 2007 08:54:04 -0700, "Beliavsky" <beli...@aol.com> wrote:
-|On Mar 28, 10:40 am, Herman D. Knoble <SkipKnobleL...@SPAMpsu.DOT.edu>
-|wrote:
-|> One example of how to read this follows. For an unknown number of lines of data
-|> add iostat and checks after each read. One could a also Trim the elements of header.
-|>
-|> Skip Knoble
-|>
-|> program testcsv
-|> integer :: dat1(2)
-|> real :: dat2(2)
-|> character(len=8) header(4)
-|>
-|> open(unit=50,file="Nye.csv")
-|> read(50,*) header
-|> print *, header
-|> do I=1,5
-|> dat2=0 ! Missing data value.
-|> dat1=0 ! Missing data value.
-|> read(50,*) dat2,dat1
-|> print *, dat2,dat1
-|> end do
-|> close(unit=50)
-|>
-|> end program testcsv
-|
-|The OP did say Fortran 77. Maybe a Fortran 77 compiler will accept the
-|code if
-|(1) it is indented to start in column 7
-|(2) "::" is removed from the declaration.
-|(3) "end program testcsv" is replaced by "end"
-|
-|I am rusty with F77, so the advice above may be incorrect. My general
-|advice is to use Fortran 95.