cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1740
Views
4
Helpful
11
Replies

ciscoworks csv separator

dragec
Level 1
Level 1

Can I change field separator in cisco works csv exports?

11 Replies 11

Joe Clarke
Cisco Employee
Cisco Employee

No. The comma is hard-coded.

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

br

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.

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

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.

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.

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

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

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.

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

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

Review Cisco Networking for a $25 gift card