View Full Version : having difficulties reading CSV data from sbp file...

Marc F. Lupien
06-13-2021, 12:41 PM
Hi there,

Does anyone has any information or examples on reading data from a CSV file (csv=comma separated values) from a sbp script ? I mean using the <open file for input as #1> and <input #1,&varx,&vary> statements.

I want to write a custom sbp file where the user inputs a position-ID and the sbp file reads a csv file where multiple x-y locations are defined and have a corresponding name. When the position name corresponding to position-ID is found, the script would move to that location.

I have tried a couple of things but the doc are very vague on the subject and so far, it doesn`t work.

The reason for this script is that I have to run the same toolpath at different locations that must be very precise and I want to decrease the possibility of error by using names instead of having the user enter position directly.

thanks in advance for any help.

06-13-2021, 03:51 PM
Sounds like you need an "IF CASE" statement. It's been asked for, but.....

You could use a bunch of "IF THEN" looking for variables using your chosen names, which in turn have the locations for positioning and then the same file is run in 2D offset from that position.

Marc F. Lupien
06-13-2021, 09:38 PM
I finally got it to work almost as intended. Using if case of if then was not an option because I create the position file from a spreadsheet.

The main drawbacks of using the open, input and close statements that I could not improve upon are:
1- the script cannot figure out if the data file' s format is not as expected... If the data is not formatted as expected the scripts spits out an error dialog and terminates (out of script control).
2- the script cannot test if the data file is present or not and give the appropriate error message.
3- the script has not easy way of detecting that we reached the end of the data file, it just gives an error message and terminates. This forces me to put a special data (marked END) at the last record in the file to test if all the data has been read without having an error.

I feel back in 1970 as far as computing is concerned sometimes when it comes to sbp files but it's still a lot better than G-code.