11-04-2008 06:34 AM
Can I change field separator in cisco works csv exports?
11-04-2008 08:17 AM
No. The comma is hard-coded.
11-04-2008 10:07 AM
great. Any way to change it in some script or somewhere?
br
11-04-2008 10:48 AM
11-04-2008 11:03 AM
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
11-04-2008 11:18 AM
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.
11-04-2008 11:25 AM
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.
11-04-2008 11:35 AM
It really depends on what you're exporting. Some fields can contain an embedded '|'. If it's a DCR export, then you're right.
11-04-2008 11:59 AM
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
11-04-2008 12:01 PM
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.
11-04-2008 11:38 PM
ok, btw is it possible to make rme inventory hardware summary report but to filter out system description field?
11-05-2008 03:42 AM
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
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide