Dromo WebinarLearn how Dromo can solve your data importing problems

Register now

Normalizing Cases

Converting all text data to a uniform case, such as lower case or upper case.

Definition

Normalizing cases refers to the process of converting all text data to a uniform case, such as lower case or upper case. This process is common when dealing with text data, especially user-generated text data, to ensure consistency and remove case-sensitivity from comparisons.

Example of normalizing cases using JavaScript

Here's a simple data object in JSON:

const data = [
  { Name: "John Doe", Email: "John.Doe@Email.com", Address: "123 Main St" },
  { Name: "Jane Doe", Email: "Jane.Doe@email.COM", Address: "456 Elm St" },
  { Name: "Bob Smith", Email: "Bob.Smith@email.com", Address: "789 Oak Ave" },
];

This JavaScript function normalizes the case of all the string fields in the data to lower case:

function normalizeCases(data) {
  return data.map((item) => {
    for (let field in item) {
      if (typeof item[field] === "string") {
        item[field] = item[field].toLowerCase();
      }
    }
    return item;
  });
}

This function uses the .toLowerCase() method, which converts a string to lower case. It iterates over each field in each item of the data. If the field's value is a string, it converts that value to lower case.

Before

NameEmailAddress
John DoeJohn.Doe@Email.com123 Main St
Jane DoeJane.Doe@email.COM456 Elm St
Bob SmithBob.Smith@email.com789 Oak Ave

After

NameEmailAddress
john doejohn.doe@email.com123 main st
jane doejane.doe@email.com456 elm st
bob smithbob.smith@email.com789 oak ave

In the "Before" table, the case of the data is mixed. After standardization, all text is converted to lower case.

Lowercasing tends to be common in text analysis because it helps to reduce the dimensionality of the data and collates words that are the same but have different casing (e.g., "Email", "email", and "EMAIL") into a single representative form ("email").