I'm new to Python and I'm trying to do a Export Features tool with the Field mapping only bringing over a handful of the fields. I have ran the tool and then copied the python code into a Notebook and it works. However I was trying to use variables of the location of the input and output database. With the variables the export works with the input and output features, but the field mapping doesn't and it exports ALL the fields. Is there a way when using variables it only exports only the fields I want it to export.
Below are some screenshots that I have come up with.
Variables:
Attempt at Export Features with Variables. I tired the wODB with and without the brackets and neither worked.
Working script when not using any variables.
Solved! Go to Solution.
It looks like you've got an f-string style variable in your field mapping parameter without the "f" at the beginning of your string. At the beginning of your string, immediately after the equals sign - where there's an "r" in front of the first quotation mark - try changing it to "rf".
It looks like you've got an f-string style variable in your field mapping parameter without the "f" at the beginning of your string. At the beginning of your string, immediately after the equals sign - where there's an "r" in front of the first quotation mark - try changing it to "rf".
Thanks @MobiusSnake That worked perfectly by adding "rf" in front of all field mapping.
or change your slashes, but you def need the f.
Try this: f"{wDB}/WaterLine" or f"{wDB}\\WaterLine"