Animal import failng

Hey Everyone,

I’m pretty new to FarmOS and have only been trailing it out so far to see what it can do. So far I have really only set up farm areas and have been tracking herd movements at a group level.

I’m currently in the process of importing all of my animals but have hit a problem where it throwing a “Sex: illegal value” on any animal marked as “Female”, all animals marked as “Male” come though fine. I have tried creating a male and female animal in FarmOS then exporting and re-importing them which results in the same problem so I’m fairly sure this is not a syntax error on my part.

Has anyone else hit this problem and if so does anyone know how to get past it?

image
error as shown in FarmOS

"Farm asset","Asset ID","","Name","Species/breed","Inventory","Date of birth","Sex","Castrated","Tag ID","Tag type","Tag location","Description","Flags","Group","Location","Archived"
"","3","","test","hereford","1","02/03/2014","Male","Yes","123456789","Chip","ear","","","","",""
"","275","","test","Undefined","1","","Female","No","","","","","","","",""

CSV from export which fails on import

Currently running on Docker image “farmos/farmos:7.x-1.6”

Any help would be appreciated.

Cheers

Hi @Rxb - welcome to the farmOS forum!

Try using “M” and “F” instead of “Male” and “Female”. I believe that is what is expected.

Notably, we do have some logic in there that will covert “male” to “M” and “female” to “F” - but I don’t think it catches capitalized “Male” and “Female”. That said, I’m not sure why “Male” seems to be working for you.

Hope that helps!

Hey @mstenta, thanks for the reply .

Yeah strangely [“Male”,“male”,“M”,“m”] all worked for the males but only “F” worked for the females. Just out of interested where is this defined, any way i can look up what is expecting for the import columns?

On another note is there any easy way to import group memberships from a list of asset names or ID tags? I can see how to add them manually into a group membership log by haven’t found a easy way to add them in bulk. Just for context the list/animal grouping is generated from the reading of RFID tags in the cattle when they come through the yards.

Thanks for the help

1 Like

Huh - strange that “female” doesn’t work. Here is where we add a “feeds tamper” plugin to convert it to “F”: https://github.com/farmOS/farmOS/blob/5ddf30f13282af7f24d1ddfd86872ba5d91d24eb/modules/farm/farm_livestock/farm_livestock.module#L257

Feel free to investigate if you have the time/interest!

is there any easy way to import group memberships from a list of asset names or ID tags

Unfortunately, the CSV importers do not support assigning group membership yet (same for location).

But, we have a shortcut for that…

Go to Assets > Animals, click the checkbox next to one or more animals and scroll to the bottom. You’ll see a set of “bulk action” buttons, one of which is “Group”. This gives you the ability to create a single group assignment log that references multiple animals.

Hope that helps!

Thanks mstenta, I’ll look into that.

Is there a way to filter for multiple names or ID tags on the animals page?

Group sizes are in the hundreds and group assignments will be a semi regular occurrence so I’m trying to figure the easiest way to create assignments from the RFID readings. So far I have just played around with adding assets ID’s into a existing ‘farm_observation’ entry in the ‘field_data_field_farm_asset’ table in the DB. This works but isn’t a great solution, next plan is to create a small program that can read my csv files from my RFID reader and create a groups via the farmos API. Sadly I don’t have any have any PHP or Drupal experience as I’m guessing the best implementation would be to create my own module.

1 Like

Is there a way to filter for multiple names or ID tags on the animals page?

Not currently. This may be more possible in farmOS 2.x via the API, but perhaps we could explore adding options to the UI as well.

Group sizes are in the hundreds and group assignments will be a semi regular occurrence so I’m trying to figure the easiest way to create assignments from the RFID readings.

Great ideas - and I’ve spoken with others who are thinking about similar challenges. It might be worth starting a dedicated forum topic to discuss these ideas.

I have just played around with adding assets ID’s into a existing ‘farm_observation’ entry in the ‘field_data_field_farm_asset’ table in the DB.

I would caution against making any changes to the database directly. In this case it’s probably harmless, but farmOS/Drupal have a database abstraction layer that handles these things for you - and ensure that necessary code is run when assets are saved. Working directly with the database without understanding these considerations could lead to weird stuff.

Sadly I don’t have any have any PHP or Drupal experience as I’m guessing the best implementation would be to create my own module.

If you have any experience with Python, you could also consider writing scripts using the farmOS.py library.

However, before you invest too much time in any solutions, I also want to reiterate that farmOS 2.x is close on the horizon (aiming for Spring), and it makes a number of big changes to the way both modules and the API work. So any work done now will need to be updated for 2.x. With that in mind, it might make sense to find a temporary solution in the near term and plan ahead to start working on a more elaborate solution once 2.x is available.

If you have any experience with Python, you could also consider writing scripts using the farmOS.py library.

Thanks for this suggestion, I didn’t know that library existed. I put together a quick python script which reads the CSV file from my RFID scanner then creates/updates a group and assigns the animals to it. Works a treat and allowed me to quick build all of my groups.

Will need to start learning about Drupal so I can look at other options down the line.

Thanks for your help!

1 Like