- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I try to read this it does not get past the 07, I want to miss up to the third comma and then grab the 3 doubles 2000,07/29/2016,10:10:14.349327,-0.0689359262076682,0.0031493396999162,1.00790136372755,,,
Is there a method in Fortran to inquire as to the list of files in a directory and return say the CSV files
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1. List-directed input considers '/' as end-of-record. Try
program jmnread implicit none character(132) :: iline = '2000,07/29/2016,10:10:14.349327,-0.0689359262076682,0.0031493396999162,1.00790136372755,,,' double precision d(3) integer :: p=0, ncom=0 ! do p=p+1 if(iline(p:p) == ',')then ! scan for commas ncom=ncom+1 p=p+1 if(ncom == 3)exit ! 3 fields skipped endif end do read(iline(p:),*)d(1),d(2),d(3) ! write(*,'(1p,3D15.4)')d end program
2. See the documentation and example code for GETFILEINFOQQ:
<Intel_Installation_Directory>/documentation_2016/en/compiler_f/common/core/index.htm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks -- worked a treat once I used '(A)' to read from the file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
subroutine lineread(iline) implicit none character(160) :: iline double precision d(3) integer :: p=0, ncom=0, p1=0 ! do p = 1,159 if(iline(p:p) == ',')then ! scan for commas ncom=ncom+1 if(ncom == 3) then p1 = p+1 exit ! 3 fields skipped endif endif end do read(iline(p1:),*)d(1),d(2),d(3) write(*,'(1p,3D15.4)')d end subroutine
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page