UPC
identity.commerce.upcUniversal Product Code — 12-digit barcode identifier for retail products. Distinct from EAN-13 (13 digits). Includes a Mod 10 check digit.
Shape
^\d{12}$| Value | Length | Shape |
|---|---|---|
| 042100005264 | 12 | matches |
| 883028594054 | 12 | matches |
| 012345678905 | 12 | matches |
| 614141000036 | 12 | matches |
| 04210000526 | 11 | rejected: one character short |
Background
Origin
GS1 US says the Universal Product Code was invented in the early 1970s, born out of a grocery industry crisis.[1] As supermarkets grew larger, manual price-keying caused checkout delays and inventory errors.[1] In 1973, a group of grocery trade associations formed the Uniform Product Code Council, which defined the numerical format that formed the basis of the code.[2] The linear barcode design came from IBM engineer George Laurer, who finalised it in 1973.[1] On 26 June 1974, a 10-pack of Wrigley's Juicy Fruit chewing gum was scanned at a Marsh supermarket in Troy, Ohio, the first commercial UPC scan.[1][2]
A UPC (technically a UPC-A) consists of 12 digits uniquely assigned to each trade item.[2] The international GS1 organisation assigns the digits used for both the UPC and the related EAN barcode.[2] GS1 US describes the GTIN as the identifying number and the UPC as the scannable element of the barcode.[1] The first 6 to 10 digits are a GS1 Company Prefix, assigned by GS1 to the brand owner.[1] The first digit also serves as a number system character.[1][2] The next 1 to 5 digits are an item reference number assigned by the brand owner.[1] The final digit is a check digit calculated from the preceding 11 digits.[1]
Use
GS1 US calls UPC-A the flagship 12-digit format used predominantly by retailers throughout North America.[1] Validate the check digit as well as the length: a 12-digit number that fails it is a typo, a mangled code or not a UPC at all. (Meridian's view)
EAN-13 was developed as a superset of UPC-A, adding an extra digit to the beginning of every UPC-A number.[2] Every UPC-A converts to its EAN-13 equivalent by prepending a 0, and the check digit does not change.[2] When joining a UPC column to an EAN-13 or GTIN column, pad both to the same length with leading zeros before comparing them. (Meridian's view)
UPC-E is a shorter version of the UPC, developed for small packages where a full 12-digit barcode may not fit.[2] Wikipedia gives UPC-A 042100005264 as the equivalent of UPC-E 425261.[2] If six-digit codes sit among twelve-digit ones, some may be UPC-E and need expanding before they will match. (Meridian's view)
Excel automatically removes leading zeros, and Microsoft lists product codes among the data this affects.[3] Microsoft suggests using Excel's Get & Transform (Power Query) to format individual columns as text when importing data.[3] Keep UPCs as text, never as integers, so that leading zeros survive. (Meridian's view) An 11-digit value in a UPC column has probably lost its leading zero, so pad it and test the check digit before rejecting it. (Meridian's view)
Where you'll meet it
The USDA's FoodData Central branded food file has a gtin_upc field, defined as the GTIN or UPC code identifying the food.[4] In that file, duplicate codes signify an update to the product, and the publication_date field distinguishes when each update was published.[4]
Sources
- [1]What is a UPC Code? | GS1 USorganisation
- [2]Universal Product Codesecondary source
- [3]Keeping leading zeros and large numbersdocumentation
- [4]FoodData Central Download Field Descriptionsdataset
Detection notes
UPC-A is a 12-digit code. EAN-13 is a superset (UPC can be converted to EAN-13 by prepending 0). Check digit uses same Mod 10 algorithm.
Use it
$ finetype infer -i "042100005264" --mode column
→ identity.commerce.upc
SELECT ft_infer('042100005264');
-- → 'identity.commerce.upc'CAST({col} AS VARCHAR)Schema
https://meridian.online/schemas/identity.commerce.upc · Frictionless type string
finetype taxonomy identity.commerce.upc -o json-schema