Joe Clarke Tue, 11/04/2008 - 08:17
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

No. The comma is hard-coded.

dragec Tue, 11/04/2008 - 10:07
User Badges:

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


br

Joe Clarke Tue, 11/04/2008 - 10:48
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

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.



Attachment: 

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

Joe Clarke Tue, 11/04/2008 - 11:18
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

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.

Joe Clarke Tue, 11/04/2008 - 11:35
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

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

dragec Tue, 11/04/2008 - 11:59
User Badges:

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

Joe Clarke Tue, 11/04/2008 - 12:01
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

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.

dragec Tue, 11/04/2008 - 23:38
User Badges:

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

Actions

This Discussion