EZ Exporter: Removing Non-Numeric Characters From Your Shopify Data

We've recently added a new Calculated Fields function in EZ Exporter for automatically stripping out non-numeric characters: strip_non_numeric_chars()

We've added this as one of our customers needed a way to export phone numbers to CSV containing only the numbers as they needed to import the data into another system that only accepts numbers. Shopify allows certain characters such as parentheses and dashes for phone numbers and this function will clean all these up automatically.

The usage is fairly simple. For example, if you have a shipping address phone number like +1 (555) 209-4427 and you want to only export the numbers, you can use this formula:

strip_non_numeric_chars({{ shipping_address.phone }})

The above formula will return: 15552094427

There's an option to make an exception for certain characters as well. If you want to keep the "+" character for instance, you can slightly modify the formula to this instead:

strip_non_numeric_chars({{ shipping_address.phone }}, except_chars="+")

This will return just the numbers and the plus sign: +15552094427

It could come in handy for custom fields as well such as Line Item Properties where a customer can enter a value in different ways.

For example, you might have a store that sells custom T-Shirts where the customer can specify their age to be printed on it when they place an order. You expect them to simply enter the age but sometimes they may put something like: "21 years old."

You can use this function combined with the search_attributes() function to clean up the data so it will only export the numbers and ignore the rest.

The formula will look something like this:

strip_non_numeric_chars(search_attributes({{ line_items.properties }}, "customer_age"))

Another type of data where this could come in handy is cleaning up prices. The data might contain the currency symbol or currency code but you only care about the actual price portion. You can use this function to do that by stripping out all non-numeric characters except the period (and comma as well if you need it).

Tags: shopify, ez exporter, howto, csv, shopify data export