0

I am trying to open with a for loop 25 csv file one after the other in IDL

I have the following code:-

The_file_list=FILE_SEARCH('D:/MapsCharts/PairedStations/','*.csv',/FOLD_CASE)

 FOR Filein =  0, N_ElEMENTS (The_file_list)-1 DO BEGIN 
 Print, Filein
 OPENR,1,filein
 temp=''
 READF,1,temp
 Station=STRMID(temp,1,13)

 ENDFOR

The first line works but I cannot get the individual file data

Can somebody advise

asynchronos
  • 583
  • 2
  • 14

2 Answers2

0

In you code Filein is an integer from 0 to N_ELEMENTS(the_file_list) - 1, not a file. So when you do:

openr, 1, filein

that is trying to open a file named 0, 1, etc. You mean:

openr, 1, the_file_list[filein]
mgalloy
  • 2,356
  • 1
  • 12
  • 10
0

The Answer is as follows

The_NETCDF_File=FILE_SEARCH('D:/Rwork/The28000files/*')

The_NETCDF_CODE=STRMID(The_NETCDF_File,23,14)

; This is the CSV file containing the 25 neighbouring stations to$
; canadiate(pilot) stations

The_file_list=FILE_SEARCH('D:/MapsCharts/PairedStations/','*.csv',/FOLD_CASE)

FOR Filein = 0, N_ElEMENTS (The_file_list)-1 DO BEGIN

Current_file=the_file_list[filein]

My_File_Names = READ_CSV(Current_File)

; Pulling out only the station ID without the extension of the csv files Station_Names=My_File_Names.field1