How can I thin my data using Surfer automation?

This article contains a sample script for thinning your data by every nth point.

To run this script:

  1. Copy the script below, or download the attached BAS file: DataThin.bas .
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer 16.
  3. Double click on Scripter.exe to launch Scripter.
  4. Press Ctrl+A to select all of the existing lines then press Delete.
  5. If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
  6. Click Script | Run to run the script.


'DataThin.bas reads the data file and writes every nth point to a new file.

Sub Main
	Debug.Print "----- ";Time;" -----"
	file1 = GetFilePath(,"dat;txt;xyz",,"Open Data File")
	n = InputBox("Read every n-th data point","Enter 'n'","2")
	file2 = Left(file1,Len(file1)-4)+"_Thinned_"+n+".dat"
	Open file1 For Input As #1
	Open file2 For Output As #2
	linenum = 0
	While Not EOF(1)
		For i = 1 To n
			Line Input #1,a
		Next i
		Print #2,a
	Debug.Print file2+" has been created."
	MsgBox(file2+" has been created.")
End Sub


Updated November 08, 2018

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.