Skip to content
Prev 165170 / 398506 Next

Trouble pulling data from a messy ASCII file...

Here is an example of some code that might do it for you::
+ 10 s   name of program that wrote this file trkplt   name of program
that wrote this file
+ 10 GORDON   machine that generated this file   machine that
generated this file
+ 10     3.7 version of program
+ 10     3.6 version of this data file
+ 10    5.81 version of Universal Library
+ 10 20081121.145730 when this file was written
+ 10 Windows_XP   operating system used   operating system used
+ *
+ *       radar characteristics
+ 11 WF-100
+ 11 20000000  A/D rate, samples/second
+ 11 7.5  bin width, m
+ 11 800  nominal PRF, Hz
+ 11  0.25  nominal pulse width, microsec
+ 11 0  tuning, volts
+ 11 3.19779  nominal wave length, cm"))
+     x <- sub("^(\\S+)\\s+(\\S+)\\s*(.*)", "\\1`\\2`\\3", line)
+     unlist(strsplit(x, "`"))
+ }
+     values <- f.parse(i)
+     switch(values[1],
+         '19'={fileName <<- values[2]},
+         '*'=NULL,   # ignore comments
+         '10'=,
+         '11'={result <<- rbind(result, c(fileName, values[3], values[2]))}
+     )
+ }
fileName A/D
rate, samples/second bin width, m
1 c:/data/WF-100/2008/20080911/trk/20080911.013115.007.17.txt
       20000000          7.5
  machine that generated this file   machine that generated this file
1                                                              GORDON
  name of program that wrote this file trkplt   name of program that
wrote this file nominal PRF, Hz
1
            s             800
  nominal pulse width, microsec nominal wave length, cm operating
system used   operating system used
1                          0.25                 3.19779
                    Windows_XP
  tuning, volts version of program version of this data file version
of Universal Library
1             0                3.7                       3.6
              5.81
  when this file was written     NA
1            20081121.145730 WF-100

        
On Wed, Dec 17, 2008 at 12:21 PM, Titan8883 <jplaney at gmail.com> wrote: