10-14-2016 04:24 PM - edited 07-23-2021 12:18 PM
There are a couple of different whitespace situations you might get yourself into, but the schematic below (from the attached example Remove Whitespace.yxmd) has you covered in all of them:
Most of the approaches make use of the Formula Tool’s trim() functionwhich, without a second argument, defaults to trimming whitespace from your strings. You can also use the Data Cleansing toolto clean your fields for you! Master it here.
Hi, how do we stop Alteryx from removing string spaces automatically?
I've created a Python script to read input excel files, but when i have sheet names with trailing spaces, Alteryx removes them automatically on the output.
The Python throws, for example "DESKTOP EG "
Using the same script in Alteryx throws "DESKTOP EG",
Then if i want to read that sheet in another macro with a Dynamic Input, i cannot, because the space was removed, so an error message appears: "Record #1...does not match a sheet or named range in ... or the Excel file is corrupt.
How can i prevent that? Thank you.
Hi jcardoso,
I am having the same problem as you.
Did you ever find a solution?
Cheers
This was really helpful thanks Matt. I was previously using the Data Cleansing tool to remove the space from all postcodes in my input file. That tool alone was taking 148 seconds. Using the formula tool with regex_replace([Postcode],"\s","") only takes 10 seconds 😁
Hi,
Very useful, thanks a lot. What if I need to remove whitespaces in 3 different colums at the same time ? Do I have to create 3 different formulas within the same formula tool ?
Thanks
Victouf, you can use a Multi-field formula to select multiple fields to run the same formula on.