Select to view content in your preferred language

Export Features Field Mapping

142
3
Jump to solution
2 weeks ago
LindseyStone
Frequent Contributor

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:

LindseyStone_0-1733860337118.png

Attempt at Export Features with Variables.  I tired the wODB with and without the brackets and neither worked.

LindseyStone_1-1733860394250.png

Working script when not using any variables.

LindseyStone_2-1733860442766.png

 

0 Kudos
1 Solution

Accepted Solutions
MobiusSnake
MVP Regular Contributor

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".

View solution in original post

0 Kudos
3 Replies
MobiusSnake
MVP Regular Contributor

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".

0 Kudos
LindseyStone
Frequent Contributor

Thanks @MobiusSnake   That worked perfectly by adding "rf" in front of all field mapping.

0 Kudos
MikeMillerGIS
Esri Frequent Contributor

or change your slashes, but you def need the f. 

Try this: f"{wDB}/WaterLine" or f"{wDB}\\WaterLine"

0 Kudos