remove_extra_whitespaces¶
remove_extra_whitespaces(str)
Description¶
Remove unwanted whitespaces (inspired from re_data dbt repo)
Usage¶
Call or Deploy remove_extra_whitespaces
?
Call remove_extra_whitespaces
directly
The easiest way to use bigfunctions
remove_extra_whitespaces
function is deployed in 39 public datasets for all of the 39 BigQuery regions.- It can be called by anyone. Just copy / paste examples below in your BigQuery console. It just works!
- (You need to use the dataset in the same region as your datasets otherwise you may have a function not found error)
Public BigFunctions Datasets
Region | Dataset |
---|---|
eu |
bigfunctions.eu |
us |
bigfunctions.us |
europe-west1 |
bigfunctions.europe_west1 |
asia-east1 |
bigfunctions.asia_east1 |
... | ... |
Deploy remove_extra_whitespaces
in your project
Why deploy?
- You may prefer to deploy
remove_extra_whitespaces
in your own project to build and manage your own catalog of functions. - This is particularly useful if you want to create private functions (for example calling your internal APIs).
- Get started by reading the framework page
Deployment
remove_extra_whitespaces
function can be deployed with:
pip install bigfunctions
bigfun get remove_extra_whitespaces
bigfun deploy remove_extra_whitespaces
Examples¶
select bigfunctions.eu.remove_extra_whitespaces(Hi Madison and Mateusz!
How are you doing?)
select bigfunctions.us.remove_extra_whitespaces(Hi Madison and Mateusz!
How are you doing?)
select bigfunctions.europe_west1.remove_extra_whitespaces(Hi Madison and Mateusz!
How are you doing?)
+--------------------------------------------+
| cleaned_string |
+--------------------------------------------+
| Hi Madison and Mateusz! How are you doing? |
+--------------------------------------------+
Use cases¶
You have a table of user-submitted comments where some users may have accidentally or intentionally added extra spaces within their text. This can affect analysis and presentation. You want to normalize the comments by removing extra spaces.
Example Table:
comment_id | comment_text |
---|---|
1 | " This is a comment . " |
2 | "Another comment." |
3 | " Yet another comment. " |
Query using remove_extra_whitespaces
:
SELECT
comment_id,
bigfunctions.us.remove_extra_whitespaces(comment_text) AS cleaned_comment_text
FROM
`your_project.your_dataset.your_comments_table`;
Resulting Table:
comment_id | cleaned_comment_text |
---|---|
1 | "This is a comment ." |
2 | "Another comment." |
3 | "Yet another comment." |
By using the remove_extra_whitespaces
function, the extra spaces within the comments are removed, leaving only single spaces between words and removing leading/trailing spaces. This makes the comments cleaner and easier to analyze, search, and present. For example, if you were doing sentiment analysis or keyword extraction, removing the extra spaces would improve the accuracy of your results.
Need help or Found a bug?
Get help using remove_extra_whitespaces
The community can help! Engage the conversation on Slack
We also provide professional suppport.
Report a bug about remove_extra_whitespaces
If the function does not work as expected, please
- report a bug so that it can be improved.
- or open the discussion with the community on Slack.
We also provide professional suppport.