1. regme_rojo
  2. RO CSVI
  3. Thursday, 16 June 2022
  4.  Subscribe via email
Hi there!
I'm just wondering if it's possible to _divide_ values from a xml / csv import field and put different parts (strings) to different fields in Joomla!.
My goal is to import contact categories and contacts to these categories.
Here's the xml file (contact item):


<LSRMitarb>
<LSR_ID>69339902</LSR_ID>
<LSR_AMTSTITEL>Title</LSR_AMTSTITEL>
<LSR_TITEL>Title2</LSR_TITEL>
<LSR_NAME>Lastname</LSR_NAME>
<LSR_NGTITEL>Title 3</LSR_NGTITEL>
<LSR_DEF_ORG>organisation</LSR_DEF_ORG>
<LSR_VORNAME>firstname</LSR_VORNAME>
<LSR_EMAIL>firstname@organisation.tdl</LSR_EMAIL>
<LSR_TEL1>7011</LSR_TEL1>
<LSR_TEL2>7011</LSR_TEL2>
<LSR_FAX>faxnr</LSR_FAX>
<LSR_ABT>division (details of the division)</LSR_ABT>
<LSR_ZIMMER>room</LSR_ZIMMER>
</LSRMitarb>


I need the LSR_ABT field to be the category of the contact. But it would be really helpful if only the first part (until "(";) would be imported as category name. The second part, inside the brackets, should go to the description of the category or into a custom field attached to the category.
Is this possible? Is there any documentation?
Thanks a lot!
Chris
Accepted Answer
Accepted Answer Pending Moderation
Hello Chris,
You can do that by following the steps.

1. Create two RO CSVI Multi replace plugin rules with Find and Replace operation.
2. The first rule will use the below regex. See attached image rule1.png. Create the rule and apply the rule on category name field in template fields. In template fields set Your field value as LSR_ABT node.


/(.*?)\s*\(.*/

3. The second rule should have three Find and Replace operations. First operation will use below regex like rule2.png. Create two more Find and replace operations like rule3.png and rule4.png. Apply the rule on category description field. In template fields set Your field value as LSR_ABT node for this field too so it gets the same value.


/[^[{(\]})]+(?=[[{(]|$)/


If all these settings are correct. You can see the modified value in Import preview page. You can then run the import. Let me know on how that goes.
Attachments (4)
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # Permalink
Accepted Answer Pending Moderation
Oh man! Thanks a lot! :D
In the mean time I figured out I would need to use regex. But to get the right regex is nearly impossible for me. :p
Thank you so much for providing me a solution. I'm going to try it out and report back.
  1. more than a month ago
  2. RO CSVI
  3. # 1
Accepted Answer Pending Moderation
So cool!
Works well and does what you said it would do!

I'm only a few steps form getting this to work. Let me post a follow up question here, because it's related.

Is there a quick regex solution to replace German Umlauts (äöÜ, etc) with "normalized" ae oe Ue values?
The category_path field will not like German Umlauts. But I have a lot of them in the XML.

I could do search and replace one by one...
  1. more than a month ago
  2. RO CSVI
  3. # 2
Accepted Answer Pending Moderation
For I already did a lowercase with the value, the search and replace only needs 4 values (ä ö ü ß). With another rule of multireplace it's simple. Done. Non need for more regex. Thanks a lot!
  1. more than a month ago
  2. RO CSVI
  3. # 3
Accepted Answer Pending Moderation
Hello,
[Is there a quick regex solution to replace German Umlauts (äöÜ, etc) with "normalized" ae oe Ue values?
The category_path field will not like German Umlauts. But I have a lot of them in the XML.
There should not be a problem in importing German Umlauts in category_path as it is UTF-8. Did you try the import?
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 4
Accepted Answer Pending Moderation
In the meantime I did the import successfully. But I don't want to have the Umlauts in the category_path, even if it's not a problem for the database.
Everything worked.
Thanks.
  1. more than a month ago
  2. RO CSVI
  3. # 5
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!