How Python and Cattle Ranching Meet
Cattle wear earrings.
Some might serve a specific purpose to aid cattle, such as earrings embedded with insecticide to keep flies out of their face. The primary purpose of most cattle earrings is to assist ranchers in managing their herds. The earrings have unique patterns of numbers or letters, allowing ranchers to identify individual cattle.
United States Department of Agriculture (USDA) calls their earrings Official Identification (official ID). There are two types of official ID. One is a metal earring with both numbers and letters. This type is called a National Uniform Eartagging System (NUES) tag. The second type of official ID is an electronically readable Electronic Identification (EID) tag. Many people familiar with EID tags call them ‘840 tags’ because they reference a 15-digit number, but they start with the numbers 840.
Here’s a picture. NUES tag on the left, 840 tag on the right. These are orange, which denotes a specific management function, but that doesn’t matter for this discussion. Further, other ear tag varieties exist, intended for herd management.
Photo by Joel K. Douglas, taken on iPhone.
Official ID is essential for US beef cattle producers as it enables traceability for both cattle and the beef produced. Traceability offers two key benefits:
- Management and Marketing: It aids in targeted marketing, promoting beef from particular ranches or states and emphasizing desired qualities, such as grass-fed or the “Certified Angus Beef” distinction.
- Food Safety: It supports the Animal Disease Traceability (ADT) program, enhancing American food safety measures during potential outbreaks of foodborne illnesses.
Many brilliant people continue to work on traceability for these two reasons. The bottom line here: cattle earrings and the associated official ID systems are indispensable.
Break break
I’ve been immersing myself in computer languages. My computer programming experience began in western Iraq, where I had to learn how to code to achieve particular goals at remote outposts. The Marine Corps unit I was attached to had contract tech support for their system, but it was often ten days to two weeks away. Not very convenient when we had an operation planned for the next day.
While I’ve dabbled in JavaScript, most of my programming work has been in Python. Python is beautiful in its simplicity and extraordinary in its capability. Further, it’s easy to understand and use because its words and rules are straightforward.
The title of this piece is “Hello, World!” because it’s the first code many people write while learning a computer language. It’s a simple way to ensure the user correctly set up the coding environment and understands the language’s basic syntax.
My curiosity with Python's capabilities further piqued when I encountered a daunting task: transferring official ID from images of cattle management records into data systems.
The simple way to do this is to visually look at the image and transcribe the official ID letters and numbers into the data system by hand. Some records have nearly a thousand animals, each with a 15-digit ear tag number (in the case of 840 tags).
I tried it this way once on a small record to determine the pain level. Nope.
Another way to do this is to run optical character recognition on the records, using a program such as Adobe Acrobat, and delete the unwanted text. Here’s a picture representative of a file. For a large herd, this text could be around a hundred pages.
Picture: https://joelkdouglas.substack.com/p/hello-world
I changed the numbers on this record, so if anyone happens across the tag numbers and looks them up, they won’t track to anything.
A workable solution. Still, mind-numbing.
Enter Python, though not without its challenges since I’m still learning the language. Many of my first code fragments did nothing or at least produced no result. Or they delivered the wrong result. Or a result that wasn’t useful. I left notes like “junk” to myself so I knew not to try it again.
There were around 25 code iterations to get to a more final product, with a dozen more to reduce errors or improve performance. Code to find 840 tag numbers. Code to cut the 840 numbers to 15 digits if the code copied too many digits. Code to find NUES tags. Code to find both tag types (they came out in the wrong order). Code to find both tag types in the correct order. Code to combine all the operations into one simple, logical bundle. Once I figured out how to get some productive results, most of the iterations improved. Sometimes, they still went down in flames.
For engineering/programming flow chart please see: https://joelkdouglas.substack.com/p/hello-world
I have a very usable product today. Now, I’m trying Python optical character recognition instead of Adobe to remove a step out of the process (no shade intended for Adobe). And what about handwritten records? Optical character recognition of handwriting is a challenge. Sometimes, I have problems reading my writing!
Are data mining and analysis a decisive factor in innovation? They can’t be decisive in and of themselves—they are a means to an end.
A better question is: Does data analysis enable us to think with more fidelity about our challenges?
The earrings or “official IDs” worn by cattle are a tangible testament to how deeply technology, particularly programming, has woven itself into traditional practices like cattle management.
How do we get beef in a grocery store with a label stating it came from ‘XYZ Ranch’ without the data to back it up? (This is a much more complex statement than just the tag number. It would be a lengthy series of articles of its own.)
How do we stop a foodborne illness outbreak before it can significantly impact the food supply?
Questions like these are the point of data analysis. By harnessing the power of languages like Python, we evolve from manually sifting through vast records to implementing automated systems that ensure accuracy and efficiency. The blend of cattle management’s time-tested techniques with modern tech streamlines processes and raises the standards for quality and safety.
Thanks for considering my perspective.
There are currently no comments. Be the first to comment on this article
Want to leave a Comment? Register now.