Skip to content
the poor coder

remove accented characters in bigquery

Poor Man
Published
Reading time
2 min read
On this page

Removing Accented Characters in BigQuery#

As a blogger and data analyst, I have come across the need to remove accented characters from text data in BigQuery. This is particularly important if you are dealing with multilingual data and want to standardize the text. In this post, I will share my experience and show you how to remove accented characters in BigQuery.

Method 1: Using REGEXP_REPLACE Function#

The easiest way to remove accented characters in BigQuery is to use the REGEXP_REPLACE function. This function replaces all occurrences of a pattern in a string with another string.

Here is how you can use it:

SQL
SELECT REGEXP_REPLACE('Café', r'[^\x00-\x7F]', '') AS result

In this example, the REGEXP_REPLACE function removes all non-ASCII characters (including accented characters) from the string Café. The result is a string without any accented characters.

You can apply this function to an entire column in a table using the UPDATE statement. Here's an example:

SQL
UPDATE mytable SET column_name = REGEXP_REPLACE(column_name, r'[^\x00-\x7F]', '')

This will update the column_name in the mytable table by removing all accented characters.

Method 2: Using TRANSLATE Function#

Another way to remove accented characters in BigQuery is to use the TRANSLATE function. This function replaces all occurrences of a set of characters in a string with another set of characters.

Here is an example:

SQL
SELECT TRANSLATE('Café', 'áéíóú', 'aeiou') AS result

In this example, the TRANSLATE function replaces all occurrences of accented characters with their non-accented counterparts. The result is a string without any accented characters.

You can apply this function to an entire column in a table using the UPDATE statement. Here's an example:

SQL
UPDATE mytable SET column_name = TRANSLATE(column_name, 'áéíóú', 'aeiou')

This will update the column_name in the mytable table by removing all accented characters.

Conclusion#

Removing accented characters in BigQuery is a simple task that can be accomplished using either the REGEXP_REPLACE or TRANSLATE function. Both methods are effective and efficient. Choose the method that works best for your particular use case.

Keep going

2023

how to sort an array

How to Sort an Array If you have an array and you want to order its elements in a specific way, you need to use a sorting algorithm. There are several sorting algorithms available, but two of the most commonly used are…

javascript2 min read
2023

jquery mobile or desktop

jQuery Mobile or Desktop? As a web developer, I have had some experience with both jQuery Mobile and jQuery Desktop. Both frameworks have their pros and cons, and which one to use really depends on the specific project…

javascript1 min read
2023

node.js folder structure

Node.js Folder Structure If you are new to Node.js, it can be daunting to create a folder structure that will work for your project. The structure you choose will depend on the size and complexity of your project. Here…

javascript1 min read
ESC