Extract the city

198 views
Skip to first unread message

Jean Yves Bouchut

unread,
Feb 1, 2021, 1:02:56 AM2/1/21
to mementodatabase
Hi
I want to extract the city from the viewmap field.
For example, I have: "73 Place de la Concorde, 75008 Paris, France" and I wish to have a "City" field with "Paris" ...
How i should proceed

Thank you

Bill Crews

unread,
Feb 1, 2021, 2:16:39 AM2/1/21
to Jean Yves Bouchut, mementodatabase
What's a viewmap field?

--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mementodatabase/5d87e9fc-0c19-444c-8d89-2ad9fefedb29n%40googlegroups.com.

Er Mo

unread,
Feb 1, 2021, 12:41:33 PM2/1/21
to mementodatabase
Hallo
Du kannst bei den Feldtyp " Ort" auswählen dass die Adresse in ein Textfeld geschriben wird . Den Text ( Adresse ) kann man mit einen Skript zuschneiten so das " Paris " überbleibt .

Hello
With the field type "Location" you can choose that the address is written in a text field. The text (address) can be cut with a script so that "Paris" remains.

Jean Yves Bouchut

unread,
Feb 1, 2021, 1:49:06 PM2/1/21
to mementodatabase
Location field...
Thanks

Jean Yves Bouchut

unread,
Feb 2, 2021, 1:10:14 AM2/2/21
to mementodatabase
Here are some clarifications:

I have an address field with: "44 Rue de Rivoli, 75004 Paris, France"
I want to extract in a city field "Paris"

I have created a calculated field but I cannot create the expression. I have tried using the "substring" and "indexOf" function, but each time I have "Invalid function name"
Thank you for your help...
----
Voici quelques précision:

J'ai un champs adresse avec:"44 Rue de Rivoli, 75004 Paris, France"
je souhaite extraire dans un champ ville "Paris"

J'ai créer un champs calculé mais je n'arrive pas à créer l'expression. J'ai essayé d'utiliser la fonction "substring" et "indexOf", mais à chaque fois j'ai "Invalid function name"
Merci de votre aide...

---
Hier einige Erläuterungen:

Ich habe ein Adressfeld mit: "44 Rue de Rivoli, 75004 Paris, Frankreich"
Ich möchte in einem Stadtfeld "Paris" extrahieren

Ich habe ein berechnetes Feld erstellt, kann den Ausdruck jedoch nicht erstellen. Ich habe versucht, die Funktionen "Teilzeichenfolge" und "IndexOf" zu verwenden, aber jedes Mal habe ich "Ungültiger Funktionsname".
Danke für deine Hilfe...

Er Mo

unread,
Feb 2, 2021, 12:45:56 PM2/2/21
to mementodatabase
Hallo
Der Feldtyp " Ort " hat die möglichkeit die Adresse in ein anderes Feld zuschreiben . Du musst ein " Text " Feld erstellen . Ich nenne es mal "Adresse" und in Feld " Ort " sagen das die Adresse in das Feld " Adresse " soll . Du hast dann im Feld " Adresse " einen " Text " Das " Berechnungsfeld " muss dan das das Felt " Adresse " zugreifen .

Bonjour
Le type de champ "Location" a la possibilité d'écrire l'adresse dans un autre champ. Vous devez créer un champ "texte". Je l'appellerai «Adresse» et dans le champ «Emplacement», je dis que l'adresse doit être dans le champ «Adresse». Vous avez alors un "texte" dans le champ "Adresse". Le "Champ de calcul" doit alors accéder au champ "Adresse".

Gilles Mons

unread,
Feb 2, 2021, 2:03:50 PM2/2/21
to Jean Yves Bouchut, mementodatabase
Bonjour Jean Yves,

Je vais voir si je e peut vous aider....

Laisser moi quelques jours....

Gilles

Er Mo

unread,
Feb 2, 2021, 4:04:37 PM2/2/21
to mementodatabase

Hallo
Mal Testen

Bonjour
Test des temps

Jean Yves Bouchut

unread,
Feb 3, 2021, 12:06:35 AM2/3/21
to mementodatabase
Merci...
C'est exactement ce que je souhaitais... J'ai simplement créer un "Déclancheur" sur "mettre à jour un enregistrement" et tout fonctionne....
Merci

 Dankeschön...
Genau das wollte ich ... Ich habe gerade einen "Trigger" für "Update Record" erstellt und alles funktioniert ....
Dankeschön

Thank you...
This is exactly what I wanted ... I just created a "Trigger" on "Update Record" and everything works ....
Thank you

Bill Crews

unread,
Feb 3, 2021, 1:11:28 AM2/3/21
to Jean Yves Bouchut, mementodatabase
In your trigger, you'll need to parse the city from the text. The next question I would ask is "How uniform are the addresses you deal with?".

If they are all very much the same, then you can use a simple, primitive way of finding the city within the address, but if you find that the addresses vary from each other a lot, then you may have get more sophisticated in your script to allow for the variations.

If you feel you need more than you have now, I recommend you take a look at the following link's page. Regular expressions can be a bit arcane, but they can also be very powerful.

After reading a little bit, if you find it hard to fathom, scroll down to the examples. Also, just Google them. They are widely used and written about.

Bill Crews

unread,
Feb 3, 2021, 1:12:44 AM2/3/21
to Jean Yves Bouchut, mementodatabase

Wojciech S.

unread,
Jan 18, 2023, 4:54:52 AM1/18/23
to mementodatabase
Hello
Can you paste here the code from that library or regular expression?
Thank you in advance

Craig Hunter

unread,
Jan 18, 2023, 9:43:22 AM1/18/23
to Wojciech S., mementodatabase
The link allows me to see the record entries, but does not allow editing the library. By editing the library I can see the javascript code. Usual workaround for tkis is to save a copy and edit that. However, this library does not allow to be copied.

For these reasons the linked library is worthless as an example for discussion.

http://libs.mobi/s/fzqj9haET

Thank you in advance

--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.

Bill Crews

unread,
Jan 18, 2023, 10:11:20 AM1/18/23
to Craig Hunter, Wojciech S., mementodatabase
Copying the library and then doing Edit Library or Scripts once worked for many years. I gather it no longer does. Maybe it's best now to send example libraries via template. Edit Library > Export. Send or attach the resulting template file. Users will Add library From template to add the library. There will be no entries, but the added library is owned by the user now and can be explored as desired (data structure, scripts, etc).

If there's a more convenient way to work around the inability to copy a library -- ideally, one that includes entries, I hope someone posts it.
__________

Das Kopieren der Bibliothek und das anschließende Bearbeiten von Bibliotheken oder Skripten hat früher viele Jahre funktioniert.  Ich nehme an, das tut es nicht mehr.  Vielleicht ist es jetzt am besten, Beispielbibliotheken per Vorlage zu senden.  Bibliothek bearbeiten > Exportieren.  Senden Sie die resultierende Vorlagendatei oder hängen Sie sie an.  Benutzer werden Bibliothek aus Vorlage hinzufügen, um die Bibliothek hinzuzufügen.  Es wird keine Einträge geben, aber die hinzugefügte Bibliothek gehört jetzt dem Benutzer und kann nach Belieben durchsucht werden (Datenstruktur, Skripte usw.).

Wenn es eine bequemere Möglichkeit gibt, die Unfähigkeit zu umgehen, eine Bibliothek zu kopieren – idealerweise eine, die Einträge enthält, hoffe ich, dass jemand sie postet.
__________

Copier la bibliothèque, puis modifier la bibliothèque ou les scripts a fonctionné pendant de nombreuses années.  Je suppose que ce n'est plus le cas.  Peut-être est-il préférable maintenant d'envoyer des exemples de bibliothèques via un modèle.  Modifier la bibliothèque > Exporter.  Envoyez ou joignez le fichier modèle résultant.  Les utilisateurs ajouteront la bibliothèque à partir du modèle pour ajouter la bibliothèque.  Il n'y aura pas d'entrées, mais la bibliothèque ajoutée appartient maintenant à l'utilisateur et peut être explorée à sa guise (structure de données, scripts, etc.).

S'il existe un moyen plus pratique de contourner l'impossibilité de copier une bibliothèque - idéalement, une bibliothèque qui inclut des entrées, j'espère que quelqu'un la publiera.

Craig Hunter

unread,
Jan 18, 2023, 10:37:58 AM1/18/23
to Bill Crews, Wojciech S., mementodatabase
I shared this one and turned on all permissions.

http://libs.mobi/cwh/example

Er Mo

unread,
Jan 18, 2023, 1:24:50 PM1/18/23
to mementodatabase
Hallo
Die Bibliothek ist von mir . Vasily hat mit den Version 4.12 , glauben ich,  die Rechte zum Kopieren Stantatmäsig auf " Gespertt " gestellt . Muss man Aktiv freigeben . Habe ich jetzt gemacht .Versuche es mal

Hi
The library is mine. With version 4.12, I believe, Vasily set the copy rights to "Locked" by default. Do you have to release active . I've done it now. Try it

Ernst

Er Mo

unread,
Jan 18, 2023, 1:58:51 PM1/18/23
to mementodatabase
Skript

var e = entry();
var zahler =0
var gps = e.field("Überschrift");
var forset='' ; var fork =','; var fors ;
for (var act in gps){
 if (fork == ','){
    zahler += 1 ;
    var forset = '' ;
   var fors = '' ;
}
 else
var fors = forset ;
if (zahler == 2 ){
//message ( fors)
var aus = fors.substring (7,)
}
//else{
 forset += gps[act] ;
   var fork = ''
   fork += gps[act] ;

}
e.set("Stadt",aus)
message ( aus)

Bill Crews

unread,
Jan 18, 2023, 4:41:41 PM1/18/23
to Er Mo, mementodatabase
The address of a park near me, as posted into my fullAddress field by Memento, is 521 Fort Washington Ave, New York, NY 10033, USA. Given that string, the following trigger script splits that info up into streetAddress, city, state, zipCode, and country. The main tool I use for this is the JavaScript String method split(delimiterString), where the value of delimiterString is a comma ("," or maybe ", ") in one case and a space (" ") in another. Here's the script. The trigger is Creating After saving and Updating After saving...

// Extracts street address, city, state, zip code,

//   & country from address portion of a Memento
//   Location field.
// Assumes US-en as a locale, so minor adjustment
//   is required for other locales.

// Location field definition puts the full address
//   (string) in the fullAddress field

var e = entry();

// Get address into a string variable to work with
var s = e.field("fullAddress");
// Get array of address components separated by commas
//   (standard method of the JavaScript String object)
var splitAddress = s.split(", "); // Make array
e.set("streetAddress", splitAddress[0]);
e.set("city", splitAddress[1]); // New York
// State & zip code are separated only by a space
var stateAndZip = splitAddress[2];  // NY 10033
var sz = stateAndZip.split(" "); // Make array
e.set("state", sz[0]); // NY
e.set("zipCode", sz[1]); // 10033
e.set("country", splitAddress[3]); // USA

Minor adjustments would get this working for your locale. This solution Is specific to the US-en locale. JavaScript has an Intl object that includes locale information, and someone who learns that could alter this script to work for any locale. That would be great, and I hope someone does. The information link for this is...

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl

See the attached screenshot of the resulting page from my library.

__________

Die Adresse eines Parks in meiner Nähe, wie von Memento in mein Feld fullAddress geschrieben, lautet 521 Fort Washington Ave, New York, NY 10033, USA.  Angesichts dieser Zeichenfolge teilt das folgende Triggerskript diese Informationen in streetAddress, city, state, zipCode und country auf.  Das Hauptwerkzeug, das ich dafür verwende, ist die JavaScript-String-Methode split(delimiterString), wobei der Wert von delimiterString in einem Fall ein Komma ("," oder vielleicht ",") und in einem anderen Fall ein Leerzeichen (" ") ist.  Hier ist das Skript.  Der Auslöser ist Erstellen nach dem Speichern und Aktualisieren nach dem Speichern ...

 // Extrahiert Straße, Stadt, Bundesland, Postleitzahl,

 //   & Land aus dem Adressteil eines Andenkens

 //   Standortfeld.

 // Setzt US-en als Gebietsschema voraus, also geringfügige Anpassung

 //   ist für andere Gebietsschemata erforderlich.

 // Standortfelddefinition setzt die vollständige Adresse

 //   (String) im Feld fullAddress

<skript>

Kleinere Anpassungen würden dies für Ihr Gebietsschema zum Laufen bringen.  Diese Lösung ist spezifisch für das US-en-Gebietsschema.  JavaScript hat ein Intl-Objekt, das Gebietsschemainformationen enthält, und jemand, der davon erfährt, könnte dieses Skript so ändern, dass es für jedes Gebietsschema funktioniert.  Das wäre großartig, und ich hoffe, jemand tut es.  Der Informationslink dazu ist...

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl

Siehe den beigefügten Screenshot der resultierenden Seite aus meiner Bibliothek.



Screenshot_20230118_161605_Memento Database.jpg

Wojciech Sikora @gmail

unread,
Jan 18, 2023, 11:39:05 PM1/18/23
to Bill Crews, Er Mo, mementodatabase
Thank you all for help. You gave me necessary knowledge.
Greetings

You received this message because you are subscribed to a topic in the Google Groups "mementodatabase" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mementodatabase/hFnuFHCCx68/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mementodataba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mementodatabase/CAORXpsTADS0W4rYUqCiEc_NeDVBbC%2B6gECHpk%2BVG3sE6NDKyGA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages