03-04-2014 03:33 PM
i am getting an error messege that reads, "Scan failed. The input string does not contain data in the expected format." when i scan from file....
is it my "format string" on the "scan from file vi"? should i just format "read from spreadsheet file" string output to their necessary formats...
Solved! Go to Solution.
03-04-2014 03:47 PM
You are adding commas as delimiters between fields with an EOL at the end of each block yet when you read you use the comma as a delimiter on the Read From Spreadsheet File. You end up with way more iterations than data. Use a new line character as your delimiter.
03-04-2014 04:08 PM
Why are you using %u as a format code?
According to the help, it is "fractional seconds with <digit> precision". You certainly don't have that with your U32 integer.
03-04-2014 04:24 PM
RavensFan is correct, you should use %d. Right click on the Format Into File and select Edit Format String. That will help you get your format string correct.
03-04-2014 04:55 PM
@kbbersch wrote:
RavensFan is correct, you should use %d. Right click on the Format Into File and select Edit Format String. That will help you get your format string correct.
applied the correction with the %d....no change in error, but lessen the read of the format string input to "%d,%d,%d,%.3f,%.3f" and NO ERRORS!
so it is how i read the combo string controls by using "%s". maybe not reading the full string "5V upper lamps/ 5V lower lamps" with just "%s" format. any suggestion on reading this full string and what format to use?
03-04-2014 05:01 PM - edited 03-04-2014 05:04 PM
A little trick to make your code a little simpler and memory efficient...
Use the Read From Text File function. Right-click on it and select "Read Lines". Yes, you can configure it to read X lines. Set the count to -1 to read all of the lines. You can then pass that array into the FOR loop and use the Scan From String instead of the Scan From File. This will result in you not reading the entire file twice.
Also, if you are trying to scan out strings, you should use "%[^,]". That will give you every character up to, but not including, a comma.
03-04-2014 05:14 PM - edited 03-04-2014 05:16 PM
For your scan from string format code try %[ /-9A-Za-z] (there is a space character between the [ and /). I think I got all the characters you're using.
03-04-2014 06:48 PM
@kbbersch wrote:
For your scan from string format code try %[ /-9A-Za-z] (there is a space character between the [ and /). I think I got all the characters you're using.
By using %[^,] you don't need to figure out every possible character. It just grabs anything until the comma. Very useful when dealing with delimited data like this.
Apok, I highly suggesting looking in the LabVIEW help for Format Specifier Syntax. It will make things a lot more clear for how to use that format string. I actually have this hanging in my office because I reference it so often.
03-04-2014 07:09 PM
@crossrulz wrote:
@kbbersch wrote:
For your scan from string format code try %[ /-9A-Za-z] (there is a space character between the [ and /). I think I got all the characters you're using.
By using %[^,] you don't need to figure out every possible character. It just grabs anything until the comma. Very useful when dealing with delimited data like this.
Apok, I highly suggesting looking in the LabVIEW help for Format Specifier Syntax. It will make things a lot more clear for how to use that format string. I actually have this hanging in my office because I reference it so often.
Yep, and I missed that in your first reply.
I used to have a copy of that hanging on the wall as well. It's time to make another one.
03-05-2014 08:47 AM - edited 03-05-2014 08:49 AM
thanks crossrulz...the input final string format that worked, "%d,%d,%d,%.3f,%.3f,%[^,],%[^]\n"
only other option (maybe not the only solution) was to go integer wise with "enums"