Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: Pull out specific numbers from unstructured text file
Replies: 13   Last Post: Aug 8, 2014 6:51 AM

 Messages: [ Previous | Next ]
 Stan Posts: 63 Registered: 6/18/12
Re: Pull out specific numbers from unstructured text file
Posted: Feb 8, 2013 12:00 AM

It worked exactly as you said. I had to put in a leading space, but no other changes were needed:

> Nmoves=sscanf(l,' Nmoves=%d');
> Nrequired=fscanf(fid,' Nrequired=%d');

------------------X--------------------

Now, there are a few other lines immediately following line lines above. I would like to pull out those lines similarly. The entire file is:

Nmoves=84 (chess win)
Nrequired=101 (chess win maximum moves requested)
TotRL = 0.26918E+08 (total IQ (RaL) in move)

tolamax= 0.89606 ras
chess one= 0.25 sh
chess two = 0.80 sh

Results for 0.27000E-01RaL moves

Throw dice = 0.2183E-03+- 0.46E-05 %
Total throw = 0.2839 +- 0.17E-03 %

Nmoves=sscanf(l,' Nmoves=%d');
Nrequired=fscanf(fid,' Nrequired=%d');
Tot_RL=fscanf(fid,' TotRL=%15f');
tolamax=fscanf(fid,' tolamax=%11f');
Moves=fscanf(fid,' Results for%16f');
Throw_dice=fscanf(fid,' Throw dice = %f+-%f');
Total_throw=fscanf(fid,' Total throw = %f +-%f');

Yet, these don't seem to be working. Am I missing something in here, or is something more than this addition required to get the extra numbers TotRL, tolamax, number before "Moves", Throw dice and Total throw?

Date Subject Author
2/7/13 Stan
2/7/13 dpb
2/7/13 dpb
2/8/13 Stan
2/8/13 dpb
2/8/13 Stan
2/9/13 Stan
2/9/13 Nasser Abbasi
2/9/13 dpb
2/9/13 dpb
2/9/13 Stan
2/9/13 dpb
2/11/13 Stan
8/8/14 apoorva