Re: How to read .csv file in fortran77?
- From: Herman D. Knoble <SkipKnobleLESS@xxxxxxxxxxxxxxx>
- Date: Wed, 28 Mar 2007 10:40:25 -0400
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
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 <zuying@xxxxxxxxx> 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
.
- Follow-Ups:
- Re: How to read .csv file in fortran77?
- From: Nye
- Re: How to read .csv file in fortran77?
- From: Beliavsky
- Re: How to read .csv file in fortran77?
- References:
- How to read .csv file in fortran77?
- From: Nye
- How to read .csv file in fortran77?
- Prev by Date: Re: http or tcp/ip
- Next by Date: Re: calculation accuracy
- Previous by thread: How to read .csv file in fortran77?
- Next by thread: Re: How to read .csv file in fortran77?
- Index(es):
Relevant Pages
|
|