LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Scan with no terminators

Solved!
Go to solution

I'm trying to use Scan to parse rows of data from an ASCII file.  The data isn't actually delimited, but instead has columns of data with space paddings like this:

 

 

Line     Date         Time       Station    Software   Slot   Profile           Revision   Elapsed Time   Stage   Retries   Notes                     Comment   
2        03-30-2020   15:44:51   ABCDE_13   3.3.0.0    2A4    MX LoPwr 100h     55.1       0:00:00        1       0                                   test profile switched  

 

 

I can't quite figure out how to grab inclusively ALL the characters including spaces in each column into new variables.

 

I'm trying something like this:

 

	ReadLine(fileHandle, rowString, -1);

	Scan(rowString,
		  "%s>%d%s[d]%s[d]%s%s[d]%s%s[w18y]%f%s%i%i%s[w24y]%s[w75y]",
		  &line,
		  // skip date
		  // skip time
		  station, 
		  // skip software version
		  slot, 
		  profile, 
		  &revision,
		  elapsed,
		  &stage,
		  &retries,
		  temp,
		  comment);

 

This results in a buffer overflow.

0 Kudos
Message 1 of 2
(1,008 Views)
Solution
Accepted by topic author ElectroLund

I found a solution, buried deep in the Scan modifiers:

%s[t-w21y]

 

 

Using a "t-" will ignore all terminators.  So then you have to use the width modifier to then stop capturing after N characters.

0 Kudos
Message 2 of 2
(967 Views)