This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Pre-Logic Script Code: | |
def concat_fields(field1, field2, field3, field4): | |
if field1.strip() == "" or field2.strip() == "" or field3.strip() == "" or field4.strip() == "": | |
return "" | |
else: | |
return field1 + "/" + field2 + "/" + field3 + " " + field4 | |
#FIELD= | |
concat_fields( !Field1!, !Field2!, !Field3!, !Field4!) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Strip preceding Zeroes | |
!FIELD!.lstrip("0") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Find and Replace Values in a Field | |
!FIELD!.replace("OriginalText", "NewText") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Pre-Logic Script Code: | |
def checkValue(c, d): | |
if c == 1: | |
return "A" | |
if c == 2: | |
return "B" | |
if c == 3: | |
return "C" | |
if c == 4: | |
return "D" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Pre-Logic Script Code: | |
def calculate(f1, f2): | |
if f2 == None: | |
return f1 | |
else: | |
return f1 + f2 | |
#Field = | |
calculate( !FIELD1!, !FIELD2! ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Say I have a list of sections, out of the 36 numbers I want 1-9 to have the format 01,02, etc. | |
They are currently ints but my final field will be a text value so I need to convert the int to a text value to add a preceding 0. | |
Add a new field | |
use field calculator to fill the column based on the int, this will now be a text value. | |
Then run the following script in the field calculator: | |
Pre-Logic Script Code: | |
def addzero(f1, f2): | |
if len(f1) == 1: | |
return "0" + f1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Excel VBA Macro: This compares two columns, if they match the the row is deleted. | |
Sub Main() | |
With Application ' Optimise so deleting rows doesnt hang | |
.ScreenUpdating = False | |
.Calculation = xlCalculationManual | |
End With | |
' Set up prompt input boxes for user to choose the columns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Excel VBA Macro: This takes a list of endpoints and automatically generates rows for each hundredth point between the two columns: beginning milepost and the ending milepost | |
Sub Main() | |
With Application ' Optimise so inserting rows doesnt hang | |
.ScreenUpdating = False | |
.Calculation = xlCalculationManual | |
End With | |
' Set up prompt input boxes for user to choose the columns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Excel VBA Macro: This checks if a cell is empty or blank, if so then it will delete the row. | |
Sub Main() | |
With Application ' Optimise so deleting rows doesnt hang | |
.ScreenUpdating = False | |
.Calculation = xlCalculationManual | |
End With | |
' Set up prompt input boxes for user to choose the columns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Excel VBA Macro: This compares two columns and if a field is empty, it will copy a value from a different field. | |
Sub Main() | |
With Application ' Optimise so deleting rows doesnt hang | |
.ScreenUpdating = False | |
.Calculation = xlCalculationManual | |
End With | |
' Set up prompt input boxes for user to choose the columns |
OlderNewer