Re: How to read .csv file in fortran77?



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

.



Relevant Pages

  • Re: How to read .csv file in fortran77?
    ... One could a also Trim the elements of header. ... Skip Knoble ... Missing data value. ... end program testcsv ...
    (comp.lang.fortran)
  • match sequence
    ... I am trying to make program that has First Input file like ... motif with First Input file and where it match print that header ... Like here it match at second Sequence so in Output it should print ... chomp $motif; ...
    (comp.lang.perl.misc)
  • Re: quickly read a formated file?
    ... ConfigPaser doesn't handle it. ... assuming the input file can be read whole. ... %HEADER ...
    (comp.lang.python)
  • RE: Extracting fields from a data file
    ... : I have input file like this: ... : header, 06-12-2004, path, ... Charles K. Clarkson ...
    (perl.beginners)
  • Re: Read input file and pass the value as parameter recursively
    ... I got an error because my input file have a header into the file like: ... The value above came from a command select Column_Name from tab1 ... One way, which should be quite efficient, for a fixed number of header lines ... read dummy ...
    (comp.unix.shell)