CMS CDRs are in JSON format. We want them in CSV format to import into SQL Server.
{
"session_id": "",
"record_type": "",
"time_stamp": "",
"correlator_index": "",
"call_leg_id": "",
"remote_party": "",
"local_address": "",
"remote_address": "",
"call_leg_type": "",
"direction": "",
"call_id": "",
"call_name": "",
"call_type": "",
"cospace": "",
"call_correlator": "",
"state": "",
"group_id": "",
"sip_call_id": "",
"display_name": "",
"remote_address": "",
"call_leg_id": "",
"reason": "",
"remote_teardown": "",
"duration_seconds": "",
"unencrypted_media": "",
"sip_call_id": "",
"db_record_type": ""
}
C:\X-Temp>jq-win64 -c . CDRs1.json > CDR12.json parse error: Expected value before ',' at line 85959, column 471
I found multiple lines with the invalid CDR ending with a double db_record_type. A simple find and replace of
"db_record_type": "cdr_acano"}, "db_record_type": "cdr_acano"}"
with
"db_record_type": "cdr_acano"}
fixes this issue.
son2csv -i CDR2021_1.json -o CDR2021_1_V2.csv
json2csv -i CDR12.json -o CDR12.csv
SELECT DATE = CONVERT(Datetime,(CONVERT(CHAR(10),[time_stamp],102)),102) ,TotalCalls = COUNT(*) FROM [CMS].[dbo].[CDR_Final] WHERE record_type = 'CallLegEnd' GROUP BY CONVERT(Datetime,(CONVERT(CHAR(10),[time_stamp],102)),102) ORDER BY CONVERT(Datetime,(CONVERT(CHAR(10),[time_stamp],102)),102)
How many calls disconnected in the same minute - typically will be the same call.
SELECT DateTime = CONVERT(Datetime,(CONVERT(CHAR(19),[time_stamp],20)),20) ,TotalCalls = COUNT(*) FROM [CMS].[dbo].[CDR_Final] WHERE record_type = 'CallLegEnd' GROUP BY CONVERT(Datetime,(CONVERT(CHAR(19),[time_stamp],20)),20) ORDER BY CONVERT(Datetime,(CONVERT(CHAR(19),[time_stamp],20)),20)