Import metadata

I have pictures that I imported in Tropy, and their metadata in a CSV file and in a JSON file. I understood that is possible to import these metadata as a JSON file but it does not work. The format is probably wrong, but my knowledge in this field is close to 0.

I don’t know if it would be easier to change the format of the JSON (and following which template?) or to work from the CSV? In the second case, do you have any advice to transform the CSV automatically to a JSON in the right format (I’ve created the template with the right fields in Tropy).

Here is the JSON one, but I cannot upload the CSV unfortunately.

{
“type”: “FeatureCollection”,
“features”: [
{
“type”: “Feature”,
“properties”: {
“location”: "Bardo National Museum, Tunis, Tunisia ",
“Dutch_caption”: “Zuilenzaal in de harem van het Bardopaleis in Tunis”,
“filename”: “Zuilenzaal in de harem van het Bardopaleis in Tunis.jpg”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
10.134036,
36.809459
]
}
},
{
“type”: “Feature”,
“properties”: {
“location”: “rue Andalouse, Tunis, Tunisia”,
“Dutch_caption”: “Twee pratende mannen in de Rue Andalouse in Tunis”,
“filename”: “Twee pratende mannen in de Rue Andalouse in Tunis.jpg”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
10.320704,
36.838094
]
}
},
{
“type”: “Feature”,
“properties”: {
“location”: “place de l’Independance, Tunis, Tunisia”,
“Dutch_caption”: "Straatgezicht in Tunis op 14 juli ",
“filename”: “Straatgezicht in Tunis op 14 juli .jpg”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
10.179486,
36.799691
]
}
},
{
“type”: “Feature”,
“properties”: {
“location”: “rue Des Libraires, Tunis, Tunisia”,
“Dutch_caption”: “Straat met boekwinkels en boekhandelaren in Tunis”,
“filename”: “Straat met boekwinkels en boekhandelaren in Tunis.jpg”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
10.17975,
36.800892
]
}
},
{
“type”: “Feature”,
“properties”: {
“location”: “Le Marché Central de Tunis, Tunis, Tunisia”,
“Dutch_caption”: “Plein met markthallen en publiek in Tunis”,
“filename”: “Plein met markthallen en publiek in Tunis.jpg”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
10.17742,
36.797504
]
}
},
{
“type”: “Feature”,
“properties”: {
“location”: “La Medina, Tunis, Tunisie”,
“Dutch_caption”: “Klanten bij een winkel in de souk van Tunis”,
“filename”: “Klanten bij een winkel in de souk van Tunis.jpg”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
10.171726,
36.798013
]
}
},
{
“type”: “Feature”,
“properties”: {
“location”: “Qasba, Tunis, Tunisia”,
“Dutch_caption”: “Gezicht op Tunis vanuit de kasba”,
“filename”: “Gezicht op Tunis vanuit de kasba.jpg”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
10.165774,
36.798858
]
}
},
{
“type”: “Feature”,
“properties”: {
“location”: “Sidi Mahrez Mosque, Tunis, Tunisia”,
“Dutch_caption”: “Gezicht op Tunis met op de achergrond de koepels van de Sidi Mahrez moskee”,
“filename”: “Gezicht op Tunis met op de achergrond de koepels van de Sidi Mahrez moskee.jpg”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
10.168487,
36.804204
]
}
},
{
“type”: “Feature”,
“properties”: {
“location”: “Monument Place de la Kasbah, Tunis, Tunisia”,
“Dutch_caption”: “Gezicht op Place de la Kasbah in Tunis”,
“filename”: “Gezicht op Place de la Kasbah in Tunis.jpg”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
10.167299,
36.797867
]
}
},
{
“type”: “Feature”,
“properties”: {
“location”: “Vieux port, Lac de Tunis, Tunisia”,
“Dutch_caption”: “Gezicht op het meer en het haventerrein van Tunis”,
“filename”: “Gezicht op het meer en het haventerrein van Tunis.jpg”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
10.191925,
36.798894
]
}
},
{
“type”: “Feature”,
“properties”: {
“location”: “Byrsa acropolis, Carthage, Tunisia”,
“Dutch_caption”: “Gezicht op de ruïnes van de Tempel van Ceres in Carthago”,
“filename”: “Gezicht op de ruïnes van de Tempel van Ceres in Carthago.jpg”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
10.322778,
36.8525
]
}
},
{
“type”: “Feature”,
“properties”: {
“location”: “Bab al Bahr, Tunis, Tunisia”,
“Dutch_caption”: “Gezicht op de Avenue de France in Tunis met stadspoort, winkels en voorbijgangers op 14 juli”,
“filename”: “Gezicht op de Avenue de France in Tunis met stadspoort, winkels en voorbijgangers op 14 juli.jpg”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
10.1756,
36.799158
]
}
},
{
“type”: “Feature”,
“properties”: {
“location”: “Bardo Palace, Tunis, Tunisia”,
“Dutch_caption”: “Exterieur van het Bardopaleis in Tunis2”,
“filename”: “Exterieur van het Bardopaleis in Tunis2.jpg”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
10.145161,
36.813161
]
}
},
{
“type”: “Feature”,
“properties”: {
“location”: “Bardo Palace, Tunis, Tunisia”,
“Dutch_caption”: “Exterieur van het Bardopaleis in Tunis”,
“filename”: “Exterieur van het Bardopaleis in Tunis.jpg”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
10.145161,
36.813161
]
}
},
{
“type”: “Feature”,
“properties”: {
“location”: “Church of White Fathers, Carthage, Tunisia”,
“Dutch_caption”: “Exterieur van de kloosterkerk van de Witte Paters in Carthago”,
“filename”: “Exterieur van de kloosterkerk van de Witte Paters in Carthago.jpg”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
10.333842,
36.867493
]
}
},
{
“type”: “Feature”,
“properties”: {
“location”: “Bardo Palace, Tunis, Tunisia”,
“Dutch_caption”: “Doorkijk naar de kamer van de sultan in het Bardopaleis in Tunis”,
“filename”: “Doorkijk naar de kamer van de sultan in het Bardopaleis in Tunis.jpg”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
10.145161,
36.813161
]
}
},
{
“type”: “Feature”,
“properties”: {
“location”: “Souk el Attarine, Tunis, Tunisie”,
“Dutch_caption”: “Arcade met zittende figuren in de parfumsouk van Tunis”,
“filename”: “Arcade met zittende figuren in de parfumsouk van Tunis.jpg”
},
“geometry”: {
“type”: “Point”,
“coordinates”: [
10.172269,
36.797789
]
}
}
]
}

Thank you very much

In order to import JSON data, you need to re-format the JSON file so that Tropy understands it. Before you start, it’s a good idea to think a little bit about how you want to end result of your data to look like in Tropy. There are some decisions you should make up front: for example, does one photo correspond to one item, or do you want items with multiple photos? Depending on this the JSON will be structured differently.

To get a good idea of what the JSON should look like, I would suggest to first create an item based on your data by hand in Tropy. That is, import the photo (or photos) and adjust metadata at the item or photo level, based on your CSV/JSON file. When you’re happy, select the item and make a copy (e.g., by pressing Ctrl/Cmd+c) and then paste the item into a simple text editor (or a text field in your browser). This should paste the item as JSON and you can use this as a template for your data.

Alternatively, based on your example above, here is one way you could import this:

[
    {
      "@type": "Item",
      "template": "https://tropy.org/v1/templates/dc",
      "http://purl.org/dc/elements/1.1/title": "Zuilenzaal in de harem van het Bardopaleis in Tunis",
      "http://purl.org/dc/elements/1.1/type": "Feature",
      "http://purl.org/dc/elements/1.1/source": "Bardo National Museum, Tunis, Tunisia",
      "photo": [
        {
          "@type": "Photo",
          "path": "Zuilenzaal in de harem van het Bardopaleis in Tunis.jpg",
          "protocol": "file",
          "template": "https://tropy.org/v1/templates/photo",
          "http://purl.org/dc/elements/1.1/title": "Zuilenzaal in de harem van het Bardopaleis in Tunis"
        }
      ]
    }
  ]

If you save this as a JSON file and put it in the same directory as the file Zuilenzaal in de harem van het Bardopaleis in Tunis.jpg you could import this as an example.

Thank you so much.
I used the first technique and it gives me the following:

{
  "@context": {
    "@version": 1.1,
    "@vocab": "https://tropy.org/v1/tropy#",
    "template": {
      "@type": "@id"
    },
    "photo": {
      "@id": "https://tropy.org/v1/tropy#photo",
      "@container": "@list"
    },
    "note": {
      "@id": "https://tropy.org/v1/tropy#note",
      "@container": "@list"
    },
    "selection": {
      "@id": "https://tropy.org/v1/tropy#selection",
      "@container": "@list"
    },
    "title": "http://purl.org/dc/elements/1.1/title",
    "date": {
      "@id": "http://purl.org/dc/elements/1.1/date",
      "@type": "https://tropy.org/v1/tropy#date"
    },
    "gpsLongitude": "http://www.w3.org/2003/12/exif/ns#gpsLongitude",
    "gpsLatitude": "http://www.w3.org/2003/12/exif/ns#gpsLatitude",
    "LocationShown": "http://iptc.org/std/Iptc4xmpExt/2008-02-29/LocationShown"
  },
  "@graph": [
    {
      "@type": "Item",
      "template": "https://tropy.org/v1/templates/generic",
      "title": "Arcade met zittende figuren in de parfumsouk van Tunis",
      "photo": [
        {
          "@type": "Photo",
          "checksum": "28824f4ca5c93d98b4fc4cf4fad9aa3e",
          "color": "rgb(184,184,184,1)",
          "density": null,
          "filename": "Arcade met zittende figuren in de parfumsouk van Tunis.jpg",
          "mimetype": "image/jpeg",
          "orientation": 1,
          "page": 0,
          "path": "C:\\Users\\Elhana\\Downloads\\TROPY\\ICA_WIDH_Images\\Arcade met zittende figuren in de parfumsouk van Tunis.jpg",
          "protocol": "file",
          "size": 1161248,
          "template": "https://tropy.org/v1/templates/id#8l_1sa2Bz",
          "angle": 0,
          "brightness": 0,
          "contrast": 0,
          "height": 3286,
          "hue": 0,
          "mirror": false,
          "negative": false,
          "saturation": 0,
          "sharpen": 0,
          "width": 2738,
          "date": "2021-11-07T16:42:10.010Z",
          "title": "Arcade met zittende figuren in de parfumsouk van Tunis",
          "gpsLongitude": "10,1722694",
          "gpsLatitude": "36,7977893",
          "LocationShown": "Souk el Attarine, Tunis, Tunisie"
        }
      ]
    }
  ],
  "version": "1.10.0"
}

Is there a way to extract automatically the data from the CSV and create the same code in JSON for the other images? or should I have to do it manually ? Which is what I was trying to escape. Thank you

Super. Here is your exported item stripped of some extra information which is not required (Tropy will extract those fields automatically from the file during import):

{
  "@context": {
    "@version": 1.1,
    "@vocab": "https://tropy.org/v1/tropy#",
    "template": {
      "@type": "@id"
    },
    "photo": {
      "@id": "https://tropy.org/v1/tropy#photo",
      "@container": "@list"
    },
    "note": {
      "@id": "https://tropy.org/v1/tropy#note",
      "@container": "@list"
    },
    "selection": {
      "@id": "https://tropy.org/v1/tropy#selection",
      "@container": "@list"
    },
    "title": "http://purl.org/dc/elements/1.1/title",
    "date": {
      "@id": "http://purl.org/dc/elements/1.1/date",
      "@type": "https://tropy.org/v1/tropy#date"
    },
    "gpsLongitude": "http://www.w3.org/2003/12/exif/ns#gpsLongitude",
    "gpsLatitude": "http://www.w3.org/2003/12/exif/ns#gpsLatitude",
    "LocationShown": "http://iptc.org/std/Iptc4xmpExt/2008-02-29/LocationShown"
  },
  "@graph": [
    {
      "@type": "Item",
      "template": "https://tropy.org/v1/templates/generic",
      "title": "Arcade met zittende figuren in de parfumsouk van Tunis",
      "photo": [
        {
          "@type": "Photo",
          "filename": "Arcade met zittende figuren in de parfumsouk van Tunis.jpg",
          "path": "C:\\Users\\Elhana\\Downloads\\TROPY\\ICA_WIDH_Images\\Arcade met zittende figuren in de parfumsouk van Tunis.jpg",
          "protocol": "file",
          "template": "https://tropy.org/v1/templates/id#8l_1sa2Bz",
          "title": "Arcade met zittende figuren in de parfumsouk van Tunis",
          "gpsLongitude": "10,1722694",
          "gpsLatitude": "36,7977893",
          "LocationShown": "Souk el Attarine, Tunis, Tunisie"
        }
      ]
    }
  ]
 }

Notice that this consists of two elements, the @context and the @graph part. The @context stays pretty much static for all the photos you want to import, and in the @graph part you would add one item object for each row in your CSV. If you show me the row in your CSV data that corresponds to the item above I can explain how to write a script to convert the data.