How to set headers for basic CDR

Hello,
The output of the CDR result “Master.csv” comes without headers just columns.
Now I need to set header to each column to be easier to read, cloud someone help me?

Thanks in advance.

How do you want to access Master.csv?

I want local basic CDR such as “cdr.conf” or “cdr_custom.conf”.

I beg your pardon, do you mean that you want to access Master.csv locall with a shell script or some other prog and define the columsn in one of the conf files?

In case of yes, forget it. The columns are more or less predefined (no header needed as defined and declred elsewhere). The custom drivers allow to add own fields.

Ok, so how can I to modify these fields and set header for each column with the easiest way?

Why do you want to change anything? This might be a good place to start: Storing Call Detail Records (CDRs)

It’s required to set database like SQL or Mysql, but don’t have database configured, I just want to create simple CDR with columns headers to define each column.

I thought that this is self-explaining (if one installs from sources), but there is the import-cdr-csv-mysql.pl script if one does not have the sources. There might be other places that also describe the fields.

Why not just write the line of column headers to the CSV file every time you
rotate the CDRs, and then let Asterisk append lines to the file as it processes
calls?

Antony.

Why do you want column headers added to the CSV file?

The fields are ALWAYS in the same order, they always mean the same, you just write whatever processing software to use the right fields for the right things. No headers needed.

If you still insist adding headers, do NOT change the file while Asterisk is running with the file open. You’d want to let Asterisk manage the CSV files on it’s one, adding stuff while it’s loaded, can change the content, without changing internal file pointers, messing things up if Asterisk is at position 0, you add 100 bytes, then Asterisk writes 200 bytes from byte 0, and overwrites whatever you’ve added.

You want to rotate the logs, then prepend the headers, and hand it off to whatever needs to process it.

Nice, how can I do it?

I want to receive the CDR result in CSV file from Asterisk with headers directly without any other software.

Asterisk doesn’t write such headers, so unless you start modifying the underlying code then it won’t happen in Asterisk.

Asterisk does not add headers to CSV CDRs. You will have to use other
software to add them if you need them, or else modify the Asterisk source code
and recompile it.

Antony.

I suppose, in that case, all you need to do, is change this file, to add the headers, when creating the file.

https://github.com/asterisk/asterisk/blob/1862a36c3b963abc7afdc645c22e014e1ea455d8/cdr/cdr_csv.c

But again, what is the reason you can’t use some other software to just prepend the headers when you copy the file from the Asterisk server?

Your requirements makes no sense to me. Asterisk is kinda like a Lego set, it bunch of building blocks you can use to create a telephone system. And just like with Lego sets you sometimes needs to combine multiple sets, to make the scene you want to create, with Asterisk you sometimes need to combine it with other software, or write your own software for certain things.

This file is as same as the default file I have tried it but there are no headers.
Also, I understand you, but I want this now for a small learning project so there no possible to add any additional software.

Unless you either patch the Asterisk source for writing the CSV file, or prepend the headers before processing it, you won’t get the headers.

Why does that fact that this is “for a small learning project” mean that it is
“not possible to add any additional software”?

What really is the reason why you need a header line in this CSV file (which,
as has been pointed out, has a fixed format with the same fields in the same
positions every time, and can therefore be read by whatever software needs to
process the data, using this information build into the software, not in the
file)?

Antony.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.