Read several files into one big data array? [message #89507] |
Wed, 22 October 2014 13:57  |
lucesmm
Messages: 26 Registered: October 2014
|
Junior Member |
|
|
I have tons of data files in the same folder. They are named correctly with the last 5 digits representing the order
Example
FILE_00001.dat
FILE_00002.dat
....
Within this files I have data formatted like this, The length of the data varies from file to file
_____________________________________
seconds Time data1 data2
189 00:03:09 111.20 770.62
3785 01:03:05 200.15 255.66
7345 02:02:25 198.83 779.16
10983 03:03:03 200.01 555.55
#Comments
#Comments
#Comments
____________________________________
I want to read all the files and storage the data in the following format
_________________________________________
data=[
00001 4189 00:03:09 111.20 770.62
00001 3785 01:03:05 200.15 255.66
00001 745 02:02:25 198.83 779.16
00001 10983 03:03:03 200.01 555.55
00002 532 02:56:00 888.01 998.20
00002 200 23:59:52 222.00 000.10
....]
_________________________________________
So this is what I have so far. But I am stock with getting the data from the title
PRO
files = file_search('\folder','*.dat', COUNT=nfiles)
for i=0, nfiles-1 do begin
nlines = FILE_LINES(files[i])
data = FLTARR(nlines)
OPENR, lunit, files[i], /get_lun
READF, lunit, data, FORMAT='(6(I, C(CHI.2, ':', CMI.2, ':', CSI.2),2F))'
CLOSE, lunit
FREE_LUN, lunit
endfor
|
|
|