text file reading, FORTRAN
bhatt vihang
vihang_75 at YAHOO.COM
Wed Jan 4 00:10:33 EST 2006
dear yin,
the solution to your problem is little trickey. one
solution is that you open your file in MS excel with
your delimitor as coma. and then save it as space
delimited text file. this will remove all coma from
your file.
since your file format is not given i make wild
guesses about the format.
if the format is specific e.g. comma appears at
regular interval.
then you can skip reading coma by making specific
format.
if you have coma at iregular interval then i will
suggest you first to write a small program which will
remove all coma from your file. and then you read as
free format. it is a two step process but i donot have
any other solution. somebody else may have any. i am
writing a small program to remove coma from your file.
PROGRAM MAIN
INTEGER, PARAMETER :: NLEN=360 !NO OF POSSIBLE
COLUMNS IN A ROW
CHARACTER(1), DIMENSION(NLEN) :: CARR
CHARACTER(1) :: DLIM_OLD=",",DLIM_NEW=" "
READ(1,10)(CARR(I),I=1,NLEN)
DO I=1,NLEN
IF(CARR(I)==DLIM_OLD)CARR(I)=DLIM_NEW
ENDDO
WRITE(2,10)(CARR(I),I=1,NLEN)
10 FORMAT(NLEN(A))
END PROGRAM MAIN
I HAVE WRITTEN PROGRAM TO PROCESS ONE LINE. YOU CAN
APPLY IN APPROPRIATE LOOP FOR ENTIRE FILE.
good luck
vihang bhatt
--- Huamei Yin <huamei at UALBERTA.CA> wrote:
> Hi,
>
> Thanks for the reply. But I actually have tons of
> files to read. The files are
> daily. So I cannot do it manually. And another issue
> is I have to display the
> station names and my boss wants me to avoid special
> characters in the station
> name.
>
> Any other ideas? Thank you.
>
> Huamei
>
>
> > A simple solution is replacing all space with _
> >
> > Youhua
> >
> > On Tue, 3 Jan 2006, Huamei Yin wrote:
> >
> >
> > Hi,
> >
> > I am reading a comma delimited text file. I used
> FORTRAN free format to read
> > since the fields lengths change. It works well for
> most cases. But in some
> > cases the station names have space in it and
> FORTRAN think space
> > means the end
> > of a field too, so it truncates the station name
> and the fields after
> > that will
> > be messed up. Dose anyone know how to solve this
> problem? Thank you
> > very much.
> >
> > Happy New Year!
> > Huamei
> >
>
Vihang Bhatt
Project Scientist
Indian Institute of Technology-Delhi
Hauz Khas
New Delhi
web: http://www.geocities.com/vihang_75/index.html
__________________________________________
Yahoo! DSL Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com
More information about the gradsusr
mailing list