CDRC RegEx Problem

89 views
Skip to first unread message

Paul Smith

unread,
Jun 8, 2015, 8:22:02 AM6/8/15
to cgr...@googlegroups.com
Hi,
I am doing some testing and evaluation of cgrates with Kamailio and Asterisk.  I have hit a problem with loading a CSV using regular expressions... 

The Master.csv is loading fine and correctly identifying the columns and pricing the calls when using a static template with a fixed direction="*out".
Now I am trying to use a regular expression in the template to use a field in the csv to determine whether it is a call *in or *out.

What I would like to do is use the value in field 3 of the csv (asterisk context) to set the direction of the imported CDR.  if the value in the csv == "from-internal" then direction should be "*out" if the value = "from-did" then the direction should be "*in".  An alternative approach would be to use the field value as the direction value ... but cgrates cdrc seems to require that Direction="*in" or "*out".

I tried the following in my /etc/cgrates/asterisk_csvcdr.json file... but the value of field 3 is passed through with no substitution.

                        {"tag": "direction", "cdr_field_id": "direction", "type": "cdrfield", "value": "~3:s/^from-internal/*out/", "mandatory": true},
             {"tag": "direction", "cdr_field_id": "direction", "type": "cdrfield", "value": "~3:s/^from-did/*in/", "mandatory": true},


What am I doing wrong?


I'm keen to get this going as it meets most of my requirements and looks like an active and well written project.


Thanks

DanB

unread,
Jun 8, 2015, 11:03:22 AM6/8/15
to cgr...@googlegroups.com
Hi Paul,

Thanks for your good words about the project. It is indeed active and well written project, at least we like to think so ;).

Regarding rewriting direction field, for the moment we don't support officially anything else than *out in that field (most probably that is the reason you cannot set it in your template, would need to deeply check it once we will support it since we had some places where we have hardcoded direction).
If you want to add the direction as informative (not to use it in your calculation), I suggest either populating category field (free form filed) or any extra field with that info (eg: call_direction).

Let me know whether this info makes sense to you.

DanB
--
You received this message because you are subscribed to the Google Groups "CGRateS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cgrates+u...@googlegroups.com.
To post to this group, send email to cgr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cgrates/b0508c8f-c5b8-4ad7-a466-c20f24523cbe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages