Topic: Removing trailing blanks from fixed field files (1 of 3), Read 56 times
Conf: Basic editing, Block operations
From: Les Hazlett
Date: Friday, December 19, 2003 02:17 PM

I am trying to remove either leading or trailing blanks from fixed length fields as I pack them into a delimited format.

1) Are there any existing macros that convert fixed length fields to delimited files?

2) Where would I look for macro examples that do similar functions?

3) Are there any commands that would help do this to avoid searching whether a string of blanks is adjacent to a delimiter?

I have read through the Webboard topics "Basic editing, Block operations", "Search and Replace", and "Converting, Translating". I have also read the "Block Operations" section of the Macro Language Reference Manual.

Thanks for any help
Les

 


Topic: Removing trailing blanks from fixed field files (2 of 3), Read 57 times
Conf: Basic editing, Block operations
From: Pauli Lindgren
Date: Thursday, January 08, 2004 08:21 AM

I made this macro that converts files with fixed lengt records into CR+LF delimited file.
After running the macro, you can use the "Remove trailing spaces" option in the User menu.





// Convert a file with fixed lengt records into text file with newlines.
// Usage:
// 1. Load the file into Vedit
// 2. Select "Config" -> "File handling" and
// set correct values to "File Type" and "Record Header size"
// 3. Run this macro.
//

#10 = Config(F_F_TYPE) // Record length
#11 = Config(F_REC_HEAD) // Record header size

if (#10<3) {
Statline_Message("Already newline delimited file")
Return
}

// Change file type to CR+LF delimited
Config(F_F_TYPE, 0)
Config(F_REC_HEAD, 0)

// Add newlines
BOF
Char(#11)
Ins_Newline
While(!At_EOB) {
Char(#10)
Ins_Newline
}




--

Pauli

 


Topic: Removing trailing blanks from fixed field files (3 of 3), Read 53 times
Conf: Basic editing, Block operations
From: Ian Binnie
Date: Thursday, January 08, 2004 10:00 PM

On 12/19/2003 2:17:16 PM, Les Hazlett wrote:
>I am trying to remove either
>leading or trailing blanks
>from fixed length fields as I
>pack them into a delimited
>format.
>
>1) Are there any existing
>macros that convert fixed
>length fields to delimited
>files?
I am unaware of any such, and obviously there have been few suggestions.

It would not be difficult.
I would do this with Goto_Col(n) Ins_Char(0x2c) for comma etc.

Then enclose in a repeat loop for each line.

Unless this was to be a regular thing I would not bother.

In practice when I want to do this I use Excel, importing the text file and setting appropriate column markers. This can then be saved as a VB macro.

If I then wanted to remove leading or trailing spaces I would export as a .csv file and do a simple manual edit in Vedit, before reimporting. NOTE if you do this make sure each column is marked as Text when importing to Excel.


>2) Where would I look for
>macro examples that do similar
>functions?
>
>3) Are there any commands that
>would help do this to avoid
>searching whether a string of
>blanks is adjacent to a
>delimiter?

See above - this is a very simple thing to do.

Hope this helps.

It all depends on what output format you want, and what program you are importing into.