Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28996 Discussions

Reading data without specific format on each line

ZlamalJakub
New Contributor III
371 Views
I need to read big data file (20MB and greater) like

1 1.0 2334.444e3
100 -1.2356e8 3.13232346
...

On each line is one integer and two reals, but they can be formatted in different way (length). This file is not generated by me and each user uses different style of file.

I am using

read(10,'(A)') line
read(line,*) i
if (i<=0) then
cycle
endif
read(line,*) i,a,b



First I read file line to variable line to check if the first integer is >0, if not I discard this line


My problem is with last read statement, which is very slow, is there any possibility to set format specification but without length of numbers specified?


Jakub Zlamal
0 Kudos
2 Replies
Steven_L_Intel1
Employee
371 Views
No - the way you're doing it now is really the best approach. What you're asking for is effectively what list-directed is doing for you now.
0 Kudos
dannycat
New Contributor I
371 Views
No - the way you're doing it now is really the best approach. What you're asking for is effectively what list-directed is doing for you now.

You could try using a 'binary' file to speed up the process. Obviously this depands upon whether you are able to create the file as unformatted yourself.
0 Kudos
Reply