Skip to main content

Table.text_cleanse

text_cleansecolumnsremoveerror_on_missing_columns

Group: Text

Documentation​

Applies the specified cleansing operations to text values in each column specified in columns.

Arguments​

  • columns: The column(s) to cleanse.
  • remove: The list of operations being performed - which elements to remove. These are performed in the order specified. The same operation can be performed multiple times. The operations are:
    • ..Leading_Whitespace: Removes all whitespace from the start.
    • ..Trailing_Whitespace: Removes all whitespace from the end.
    • ..Duplicate_Whitespace: Removes all duplicate whitespace replacing it with the first whitespace character of the duplicated block.
    • ..All_Whitespace: Removes all whitespace. - ..Newlines: Removes all newline characters. Line Feed and Carriage Return characters are considered newlines.
    • ..Leading_Numbers: Removes all numbers from the start.
    • ..Trailing_Numbers: Removes all numbers from the end.
    • ..Non_ASCII: Removes all non-ascii characters.
    • ..Tabs: Removes all tab characters.
    • ..Letters: Removes all letters.
    • ..Numbers: Removes all numbers.
    • ..Punctuation: Removes all characters in the set ``,.!?():;'"`.
    • ..Symbols: Removes anything that isn't letters, numbers or whitespace from the string.
  • error_on_missing_columns: If True, an error is raised if any of the specified columns are not found in the table. If False, missing columns are ignored.

Returns​

  • A Table of all records, with the cleansing operations performed on the specified columns. Original columns are removed and replaced with the cleansed columns.

Examples​

Remove leading and trailing spaces from cells.​

     table = Table.new [["Input"], ["  Hello  "], ["  World  "]]
cleansed = table.text_cleanse ["Input"] [..Leading_Whitespace, ..Trailing_Whitespace]

Returns a Table

Input
Hello
World