Data and storage

Clean a CSV column

normalize
Rewrite a phone column in one notation and flag rows that need a person.
Try it
id,phone,status
1,03-5253-8111,ok
2,090-1234-5678,ok
3,03-1234-5678,check
4,092-513-5612,ok

How it works

Clean data in bulk without losing anything: rows that can be cleaned get the normalized number, and the rest keep their value with a check status.

Because japan-phone does not guess, a row like 03-1234-5678 is flagged instead of being saved as if it were real.

In each language

import { normalize } from "@kurashina-design/japan-phone";

// Rows of a CSV file with a phone column. Rows that cannot be cleaned keep their value and are flagged.
const rows = [["1", "03(5253)8111"], ["2", "090 1234 5678"], ["3", "03-1234-5678"], ["4", "TEL:092-513-5612"]];

console.log("id,phone,status");
for (const [id, phone] of rows) {
  const number = normalize(phone);
  console.log([id, number ? number.national : phone, number ? "ok" : "check"].join(","));
}

Output:

id,phone,status
1,03-5253-8111,ok
2,090-1234-5678,ok
3,03-1234-5678,check
4,092-513-5612,ok