Q: I want to get my contour map into CMG so I've exported them to BNA, but they aren't loading. CMG support says it's the headers that are the issue. Surfer is exporting a header with the z value in column A and an empty column in column B, but CMG expects the z value in column B and an empty column in column A. How can I update the header information without having to manually go through thousands of lines?
A: This is the perfect instance where a script can do all this manual work for you.
- In Windows Explorer, navigate to C:\Program Files\Golden Software\Surfer 16\Scripter and double click on Scripter.exe to launch Scripter.
- Delete the existing two lines of script and copy/paste in this script:
Sub Main 'Initialize Surfer Dim SurferApp, Wks, WksRangeA, WksRangeB As Object Set SurferApp = CreateObject("Surfer.Application") SurferApp.Visible = True 'Make Surfer visible 'Prompt the user for the name of the data file to process. InFile = GetFilePath("","BNA", CurDir(), "Select data file", 0) 'Open BNA Set Wks = SurferApp.Documents.Open(FileName:=InFile) Set WksRangeA = Wks.Columns(Col1:=1, Col2:=1) Set WksRangeB = Wks.Columns(Col1:=2, Col2:=2) 'Loop through rows numrows = WksRangeA.RowCount For i=1 To numrows 'If col B in row is empty, cut col A cell for that row and paste it into col B If WksRangeB.Cells(i)="" Then WksRangeA.Cells(i).Cut WksRangeB.Cells(i).Paste End If Next 'Saves the BNA to the same name Wks.Save 'Closes Surfer SurferApp.Quit End Sub
- Click Script | Run.
- Choose your BNA file and click Open.
If you have multiple BNA files, you can update line 8 of this script to instead loop through BNA files in a certain directory.
Updated November 8, 2018