Topic: counting special characters (1 of 4), Read 27 times
Conf: Basic editing, Block operations
From: Greg Ehrig
Date: Wednesday, November 30, 2005 09:18 PM

So, I have this problem:

I have a set of large files that are output from a database.

The column delimiter is 'Ç'.

There _should_ be 38 'Ç's per line -- ie 38 columns in the original table. Sometimes there are not. There may be, say, 36 'Ç's on a particular line.

What I want to do is, write a macro that Checks each line in the file to see if it has 38 'Ç's. If it does not, delete the line or move it into a different file.

Is there an easy and fast way to do this?

 


Topic: counting special characters (2 of 4), Read 27 times
Conf: Basic editing, Block operations
From: Christian Ziemski
Date: Thursday, December 01, 2005 02:43 AM

On 11/30/2005 9:18:40 PM, Greg Ehrig wrote:

>I have a set of large files that are output from a database.
>The column delimiter is 'Ç'.

>There _should_ be 38 'Ç's per line -- ie 38 columns in the original table.
>Sometimes there are not. There may be, say, 36 'Ç's on a particular line.

>What I want to do is, write a macro that
>Checks each line in the file to see if it has 38 'Ç's. If
>it does not, delete the line or move it into a different
>file.

>Is there an easy and fast way to do this?

You can try to use
http://www.ziemski.net/vedit/macros/check-dpl.vdm
as example.
This macro checks a file for same number of delimiters per line and reports the result.
You can modify it to do something with the wrong lines then.
There are some hints how to call it in the macro itself (in the comment lines at the beginning).

Christian

 


Topic: counting special characters (3 of 4), Read 25 times
Conf: Basic editing, Block operations
From: Greg Ehrig
Date: Thursday, December 01, 2005 02:18 PM

Much obliged Christian. This is exactly what I was hoping for.

 


Topic: counting special characters (4 of 4), Read 23 times
Conf: Basic editing, Block operations
From: Paul Breen
Date: Thursday, December 01, 2005 07:50 PM

I've run the macro and it is a handy tool but I think you can simplify it.
If you have the delimiting character, you do not need to ask how many are expected because the first line can be assumed to be "correct", since any different sum of delimiters in another line will fail the test.

Vedit est optime. CodeWright est mortuus.