Hi @tbaving
Try to use the transformer StringReplacer.
Thanks,
Danilo
Hi @tbaving,
If you want to change multiple attribute names you can use the BulkAttributeRenamer. Set the Action to String Replace, Text to Find to "-", and String (to replace) to "_".
I've attached an example workspace for you to test out for yourself.
-Chris
rename-attribute-name.fmwt
Dear all, with the inspecotor it works.... But if i add the spatialite writer it writes again an underscore instead of - . What im doing wrong? Many thanks guys.
Sorry i changed it. I mean _ to -.. change the topic tiltle.....
Hi @tbaving,
The answer provided by @ChrisAtSafe is the best way to do this. Since the correct formatting is showing in the Data Inspector it may be that spatialite doesn't except the hyphen character so FME automatically changes it to one it will.
This note: "SQL names cannot contain forbidden characters (such as spaces, brackets, colons, hyphens and so on" found here: https://www.gaia-gis.it/spatialite-3.0.0-BETA/spatialite-cookbook/html/basic-sql.html supports my suggestion.
There are some other articles online that suggest you can include forbidden characters in an SQLite field name if they are escaped in quotes or brackets, but sites contradict themselves on how this should be written:
https://stackoverflow.com/questions/23770480/sqlite-table-and-column-name-requirements?rq=1http://sqlite.1065341.n5.nabble.com/special-characters-as-column-names-td36677.html
Please consider voting for this idea to support special characters in writers and include a comment with details on the specific writer and your use case.
Dear all, with the inspecotor it works.... But if i add the spatialite writer it writes again an underscore instead of - . What im doing wrong? Many thanks guys.
Hi @tbaving,
It may be that the spatialite doesn't except the - character so FME automatically changes it to one it will.
This note: "SQL names cannot contain forbidden characters (such as spaces, brackets, colons, hyphens and so on" found here:
https://www.gaia-gis.it/spatialite-3.0.0-BETA/spatialite-cookbook/html/basic-sql.html supports my suggestion.
Hi @tbaving,
The answer provided by @ChrisAtSafe is the best way to do this. Since the correct formatting is showing in the Data Inspector it may be that spatialite doesn't except the hyphen character so FME automatically changes it to one it will.
This note: "SQL names cannot contain forbidden characters (such as spaces, brackets, colons, hyphens and so on" found here: https://www.gaia-gis.it/spatialite-3.0.0-BETA/spatialite-cookbook/html/basic-sql.html supports my suggestion.
There are some other articles online that suggest you can include forbidden characters in an SQLite field name if they are escaped in quotes or brackets, but sites contradict themselves on how this should be written:
https://stackoverflow.com/questions/23770480/sqlite-table-and-column-name-requirements?rq=1http://sqlite.1065341.n5.nabble.com/special-characters-as-column-names-td36677.html
Please consider voting for this idea to support special characters in writers and include a comment with details on the specific writer and your use case.
And what about geopackage? Normally in qgis it accepts dashes. But in FME it automaticaly changes back to _
Here's a workaround for the Geopackage format that probably isn't condoned by Safe at all ;-)
Open the file <FME Home>\metafile\geopackage.fmf in a text editor.
Modify lines 281 and 282 (or thereabouts, depending on your FME version) to remove the "-" character, the lines should read like this, notice the lack of the "-" character:
MACRO _FeatureTypeInvalidCharacters \\\"{}()',@&`~!#$%^*+=|t]:;<>?./
MACRO _AttributeInvalidCharacters \\\"{}()',@&`~!#$%^*+=|_]:;<>?./
Restart FME. You should now be able to create both feature types and attributes containing dashes:
Tested with FME 2018.1 and QGIS 2.18.10, but no guarantees given whatsoever...
Hi @tbaving,
The answer provided by @ChrisAtSafe is the best way to do this. Since the correct formatting is showing in the Data Inspector it may be that spatialite doesn't except the hyphen character so FME automatically changes it to one it will.
This note: "SQL names cannot contain forbidden characters (such as spaces, brackets, colons, hyphens and so on" found here: https://www.gaia-gis.it/spatialite-3.0.0-BETA/spatialite-cookbook/html/basic-sql.html supports my suggestion.
There are some other articles online that suggest you can include forbidden characters in an SQLite field name if they are escaped in quotes or brackets, but sites contradict themselves on how this should be written:
https://stackoverflow.com/questions/23770480/sqlite-table-and-column-name-requirements?rq=1http://sqlite.1065341.n5.nabble.com/special-characters-as-column-names-td36677.html
Please consider voting for this idea to support special characters in writers and include a comment with details on the specific writer and your use case.
Actually, dashes seem to work just fine in GeoPackage, see my workaround below.