Help with CSV Import

I am getting ready to import my cattle herd into farmOS. I visited https://farmos.org/guide/import/ and watched the video. My question is on column header names. Is this fixed/limited to what is listed on the Animal import page and in the template file (Name, Archived, Description, Parent IDs, Parent names, Nicknames, Date of birth, Species/breed, Sex, Castrated, Tag ID, Tag type, Tag location)?
In the video, it was stated that unused columns could be deleted, so I wasn’t sure how fixed of a format the import process used or if it simply created whatever is specified in the CSV file. Wondering if I can add more Tag ID’s, Tag type’s and Tag locations to each animal? e.g. ideally, I would be able to specify ear tag, bangs tag and EID tag for each animal in the CSV file for import. Thank you for any help/clarification provided.

1 Like

Hi @ctomayer - good questions.

My question is on column header names. Is this fixed/limited to what is listed on the Animal import page and in the template file (Name, Archived, Description, Parent IDs, Parent names, Nicknames, Date of birth, Species/breed, Sex, Castrated, Tag ID, Tag type, Tag location)?

Yes, ONLY the columns in the template will be accepted.

Wondering if I can add more Tag ID’s, Tag type’s and Tag locations to each animal? e.g. ideally, I would be able to specify ear tag, bangs tag and EID tag for each animal in the CSV file for import. Thank you for any help/clarification provided.

Unfortunately, this won’t work. The CSV importer only includes columns for a single ID right now. I know there are a lot of folks who have more than one ID, though, so this would be a good feature request to open up.

Is it feasible for you to import one ID tag and then fill in the other one manually on each animal? Or - perhaps use the “Name” for one ID and the ID Tag for another? Just ideas… not sure if that would make sense for you.

The CSV importers in general are pretty limited in what they can do. The other more capable option is to use the farmOS.py Python library to write a script that reads your CSV and pushes records to farmOS over the API. But this is certainly more involved, requires knowing Python, etc.

I’m definitely interested in exploring more options for CSV import in general. FWIW, we are currently using the Feeds module: https://drupal.org/project/feeds - which is pretty flexible in some ways, but inflexible in others.

In the future it would it be possible to add an import column for Location. Idea being once imported the animals would end up being automatically placed in their correct paddock (assuming it exists already in farmos).

1 Like

Yes! And in fact @megandalster recently did some work on this: https://github.com/farmOS/farmOS/issues/199#issuecomment-659446449

So I think the next step is to review that and see if it can be reused to provide the additional columns in farmOS core CSV importers.

1 Like

Hello everyone,

I am preparing to import harvest data from a CSV file to FarmOS. I’m filling the “log_farm_harvest_template.csv” file from FarmOS.
I’m wondering if the sequence of the columns of this file are important ? can i re-order the column sequence in a more beneficial way for me ?

Thanks a lot for your answer !

1 Like

Hi @nathanrosenfeld - welcome to the forum!

The order of CSV columns does not matter - you can rearrange them however you’d like. You can also omit ones that you don’t need (unless they are required fields). As long as you leave the header names the same, it should work.

2 Likes

thanks !

1 Like

Hi @mstenta, thank you for developing FarmOS. It works very well! I recently started to use FarmOS and would like to use the CSV import functionality for the column Location to map assets like Plantings. Do you know when this functionality will be implemented? Cheers, Hugo

1 Like

Hi @hugo - welcome to the farmOS community!

Unfortunately, there probably won’t be any new development to the farmOS 1.x CSV importers, as we are focusing all our efforts on farmOS 2.x at this time. The 2.x CSV importers are in development.

In the meantime, one way you can workaround the lack of “Location” column in the 1.x Asset importers is by running a second import of Logs, which assign the location of assets.

If you haven’t already, I would recommend reading how asset location works in farmOS: Movements and location - farmOS.org

Basically, location is determined by logs that “move” an asset somewhere. So asset records by themselves have no concept of location - they need a log to give them that. So ultimately, you need to create two records either way.

You could, for example, create two CSVs: one that lists all your Plantings, and one that lists the seeding/transplanting dates and locations of those Plantings (imported as “Seeding” or “Transplanting” logs).

Hope that helps! Give it a try and let us know how it works for you!

Thank you, @mstenta. I managed to work with the workaround. Also the Movements and Locations link suggested by you helped a lot. Good luck with farmOS 2.x!

1 Like