Error with CSV import Compound field including dates

I have a Compound field consisting of two Dates and one Text field. I’m trying to import items from CSV, but the import keeps failing with the error:

[2024-05-18 00:10:40] Fatal Error: Uncaught TypeError: key(): Argument #1 ($array) must be of type array, string given in /home/utweb/utw11209/public_html/wp-content/plugins/tainacan/classes/importer/class-tainacan-csv.php:198
Stack trace:
#0 /home/utweb/utw11209/public_html/wp-content/plugins/tainacan/classes/importer/class-tainacan-csv.php(198): key()
#1 /home/utweb/utw11209/public_html/wp-content/plugins/tainacan/classes/importer/class-tainacan-importer.php(680): Tainacan\Importer\CSV->process_item()
#2 /home/utweb/utw11209/public_html/wp-content/plugins/tainacan/classes/importer/class-tainacan-importer.php(884): Tainacan\Importer\Importer->process_collections()
#3 /home/utweb/utw11209/public_html/wp-content/plugins/tainacan/classes/importer/class-tainacan-bg-importer.php(39): Tainacan\Importer\Importer->run()
#4 /home/utweb/utw11209/public_html/wp-content/plugins/tainacan/classes/class-tainacan-background-process.php(324): Tainacan\Background_Importer->task()
#5 /home/utweb/utw11209/public_html/wp-content/plugins/tainacan/classes/libs/wp-background-process.php(184): Tainacan\Background_Process->handle()
#6 /home/utweb/utw11209/public_html/wp-includes/class-wp-hook.php(324): Tainacan_WP_Background_Process->maybe_handle()
#7 /home/utweb/utw11209/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#8 /home/utweb/utw11209/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#9 /home/utweb/utw11209/public_html/wp-admin/admin-ajax.php(207): do_action()
#10 {main}
thrown - /home/utweb/utw11209/public_html/wp-content/plugins/tainacan/classes/importer/class-tainacan-csv.php - Line: 198
[2024-05-18 00:10:40] Process aborted

I’ve formatted the column in the csv like:

“1322-01-01”,“1324-12-31”,“circa 1322-1324.”

I also tried without quotes around the first two subfields, and with different date formates (MM/DD/YYYY, etc)

I’m able to successfully import the same file (which includes other compound fields) if I don’t map this compound date field, so I think the error must be somewhere there.

Hi @lizfischer,
Could you please show me the column header for the CSV file that includes the compound metadata description?

I’m not creating the schema using the CSV, trying to import into an existing collection. This is the collection’s metadata schema:


Does the CSV column header matter in that case? It didn’t for my other compound field (“Given At” above)–I just set the mapping during the import process

When mapping data to a child metadata, the compound header should contain the information of its children.

Our UI has a bug that allows you to map even if it does not contain… sorry, we have fixed this recently and shall release an update soon. But right now you should be able to perform the mapping and the import correctly as long as your compound field in the CSV contains the child metadata info. In your case, I believe it should be something like this:
Date|compound(Earliest|date,Latest|date,Date Text|text)

Take a look at how the headers are built when you Export your collection via CSV, it should match that.

Thanks, that worked!

I encountered another issue with my Given At field–I did the same thing, updated the header to match the Export header: Given At|compound(GeoCoordinate|geocoordinate,Certainty|text,Given At (text)|text,Place|relationship)|display_no

But when I import, the UI doesn’t show the Place|relationship field as an option in mapping. I tried importing the same file I exported, and this was the UI:

Which produced the error :

[2024-05-21 16:47:56]   Mismatch count headers childrens and row columns. file value:"47.690537544237685,-117.47973765515523",Certain,"Cathedral at Hereford",2011
[2024-05-21 16:47:56]   failed on item 0

I figured out this was beacuse the importer did not like that there are parentheses in the subfield name “Given at (text).” I change the name of that field in the CSV only (not actually in the metadata schema) and it worked great!

Seems like something worth noting if you weren’t already aware, though, since the Exporter in this case produces a file that can’t be re-imported without modification. Same thing with date formats–when exported, it gave “January 30, 1347” but the importer expects YYYY-MM-DD

Anywho, I can work around those! Thank you for your help!

Uhm… let’s try yo identify what is happening there. Can you redo the same but removing the “(text)” sentence from the metadata name? I’m guessing there might exist some conflict there because the notation is too similar.

Regarding the export producing something that cannot be re-imported… yeah I agree with you, we should have options to decide whether we should export “raw” values or their readable form, as happens now. Same could be said about Relationship values, which instead of exporting as IDs actually show item title.

Yes, the parentheses were the issue–I removed those and it worked fine. That was my thought, too.

1 Like