Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

ciscoworks csv separator

Can I change field separator in cisco works csv exports?

11 REPLIES
Cisco Employee

Re: ciscoworks csv separator

No. The comma is hard-coded.

New Member

Re: ciscoworks csv separator

great. Any way to change it in some script or somewhere?

br

Cisco Employee

Re: ciscoworks csv separator

You'd have to write your own intermediate parser. For example, here is one I wrote in Perl that will parse the included CSV file, and turn the commas into tabs.

Silver

Re: ciscoworks csv separator

Heres one in sed that changes commas to bars:

# sed script to convert case (d) to bar-delimited records

s/^ *\(.*[^ ]\) *$/|\1|/;

s/" *, */"|/g;

: loop

s/| *\([^",|][^,|]*\) *, */|\1|/g;

s/| *, */|\1|/g;

t loop

s/ *|/|/g;

s/| */|/g;

s/^|\(.*\)|$/\1/;

#---end of script---

awk is even easier and quicker..heres no commans but spaces instead

awk -F"," -f file.csv file.txt

Cisco Employee

Re: ciscoworks csv separator

There is a problem with line 5 of your sed script. You're missing \(...\). Also, this script won't work if your CSV records contain embedded '|' characters. It will not quote those fields on output.

Silver

Re: ciscoworks csv separator

isnt a bar an invalid character inside LMS ? :)

Good catch on the missing bit... I whipped it off in a few seconds while you were ansswering ahead of me.

Cisco Employee

Re: ciscoworks csv separator

It really depends on what you're exporting. Some fields can contain an embedded '|'. If it's a DCR export, then you're right.

New Member

Re: ciscoworks csv separator

my problem is exporting devices and some fields contains comma that is also used as field separator. So best soulution would be to make cw at source not to use comma. It is better then using replacement afterwords

Cisco Employee

Re: ciscoworks csv separator

The fields that contain commas should be quoted. My Perl script handles this as well as producing tab-delimited output with fields that contain embedded tabs quoted. All modern CSV parsers should be able to handle quoted fields.

If you are finding fields in LMS exports that contain commas are NOT quoted, please let me know. I have fixed all of the instances I have found so far.

New Member

Re: ciscoworks csv separator

ok, btw is it possible to make rme inventory hardware summary report but to filter out system description field?

Silver

Re: ciscoworks csv separator

Just create a custom report template and choose these Template rules:

System Name: equals :all

And: Updated At:=: all

And: System: Contact: equals: all

And: Chassis Serial Number: equals : all

And: Processor:Ram Size (MB):=: all

And: Processor: NVram Size:=: all

And: Processor NVram Used (kb)=: all

And: Flash Device: Flash Device Size (MB):=: all

Thats all the columns that exist in the original canned report.

Or if you feel adventerious, just use awk on an exported csv of the summary report and drop $3

262
Views
4
Helpful
11
Replies
CreatePlease to create content