Req: File manipulator

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I'm looking for a program to convert variable length records to fixed
length, specifying the record length I need.

Also the ability to replace/insert the end-of-line delimiter would be great
(i.e., CR/LF or LF alone).


Dave
(Remove uppercase letters for e-mail)
(e-mail address removed)
 
Hello Dave

You could try http://www.iconv.com, they have an online converter that
converts a variable length delimited format to a fixed record format,
I use it often to convert tab-delimited files to fixed record files.
It also allows you to specify the line terminator between Unix- and
DOS type (LF, or CR/LF). Regards -- John
 
Sietse Fliege put pen to paper and... uhh.. put fingers to keyboard and
typed:

This looks like a good tool for delimited or fixed column fields.

That's not what I'm needing.

I've got text data of in varying record lengths. In the example below,
the "|" character designates the actual end of the record.

NOW IS THE TIME FOR ALL GOOD MEN|
TO COME TO THE AID OF THEIR COUNTRY.|

What I want is a utility to prompt for the physical end of line so that I
have this instead:

NOW IS THE TIME FOR ALL GOOD MEN |
TO COME TO THE AID OF THEIR COUNTRY. |

Of course, if you can't see this post in a fixed (monospace) font, it
really doesn't mean a whole lot... lol.
 
Dave said:
Sietse Fliege put pen to paper and... uhh.. put fingers to keyboard
and typed:


This looks like a good tool for delimited or fixed column fields.

That's not what I'm needing.

I've got text data of in varying record lengths. In the example
below, the "|" character designates the actual end of the record.

NOW IS THE TIME FOR ALL GOOD MEN|
TO COME TO THE AID OF THEIR COUNTRY.|

What I want is a utility to prompt for the physical end of line so
that I have this instead:

NOW IS THE TIME FOR ALL GOOD MEN |
TO COME TO THE AID OF THEIR COUNTRY. |

Of course, if you can't see this post in a fixed (monospace) font, it
really doesn't mean a whole lot... lol.

If I understand you correctly, for the above example: it looks like you
can do that with a texteditor that sports a few widely used features.

+ set the tabwidth (for this document) to the desired width
+ search | and replace with ^t| where ^t = [TAB]
+ do a "replace tabs with spaces" operation
+ search current EOL delimiter and replace with delimiter of choice

HTH
 
Sietse Fliege put pen to paper and... uhh.. put fingers to keyboard and
typed:

I've got text data of in varying record lengths. In the example
below, the "|" character designates the actual end of the record.

NOW IS THE TIME FOR ALL GOOD MEN|
TO COME TO THE AID OF THEIR COUNTRY.|

What I want is a utility to prompt for the physical end of line so
that I have this instead:

NOW IS THE TIME FOR ALL GOOD MEN |
TO COME TO THE AID OF THEIR COUNTRY. |

Of course, if you can't see this post in a fixed (monospace) font, it
really doesn't mean a whole lot... lol.

If I understand you correctly, for the above example: it looks like you
can do that with a texteditor that sports a few widely used features.

+ set the tabwidth (for this document) to the desired width
+ search | and replace with ^t| where ^t = [TAB]
+ do a "replace tabs with spaces" operation
+ search current EOL delimiter and replace with delimiter of choice

HTH

Two things:
1. The "|" character above is only a representation for illustration
purposes. It doesn't actually exist in the file. That's really no matter -
I can put that in easy enough.

2. I'm interested in knowing what text editor does a "replace tabs with
spaces" operation? NoteTab, Visual SlickEdit (payware), Editor2,
NoteXPad, ... of all the ones I have on my system, none have this option,
unless it's "replace tab with x spaces", which does no good as some lines
may have 2 spaces, some may have 100.
 
Dave said:
Two things:
1. The "|" character above is only a representation for illustration
purposes. It doesn't actually exist in the file. That's really no
matter - I can put that in easy enough.

I see. You don't have to put it in.
I assume the lines just have a normal [EOL]
You then can just replace [EOL] with [TAB][EOL]
E.g. in Editor2 you can choose the special characters:
Replace $0D with $09$0D
2. I'm interested in knowing what text editor does a "replace tabs
with spaces" operation? NoteTab, Visual SlickEdit (payware), Editor2,
NoteXPad, ... of all the ones I have on my system, none have this
option, unless it's "replace tab with x spaces", which does no good
as some lines may have 2 spaces, some may have 100.

In the example you gave:
NOW IS THE TIME FOR ALL GOOD MEN
TO COME TO THE AID OF THEIR COUNTRY.
you first convert this (with e.g. Editor2) to:
NOW IS THE TIME FOR ALL GOOD MEN[TAB]
TO COME TO THE AID OF THEIR COUNTRY.[TAB]
Then you convert tabs to spaces (with e.g. NoteXPad)
Menu: Edit|Convert|Tabs to Spaces.
If you set the Tab Size to 40, the lines, originally having 32 and 36
characters, now will have 8 and 4 trailing spaces respectively.
 
Dave wrote in said:
of all the ones I have on my system, none have this option,
unless it's "replace tab with x spaces", which does no good as some lines
may have 2 spaces, some may have 100.

A DOS program that should be able to fix the text formatting for you,
FIXTEXT by Bruce Guthrie, found here:
<http://users.erols.com/waynesof/bruce.htm>

From the long feature list (in fixtext.txt), among
other things it:
* Can translate tab characters into spaces.
* Can remove leading and/or trailing spaces from lines.
* Can remove blank lines from files.

So, you could do a first pass to convert tabs, then a second run to
remove trailing spaces. Done. Or?

Notice, for all his (useful & handy!) command line programs the
following applies:
<quote>
These programs are written and compiled in DOS, not Windows. They
should work fine under Windows but forget handling things like
long file names under Win95, Win98, WinME, Win2000, and WinNT.
</quote>
source: <http://users.erols.com/waynesof/bruce.htm>:

ps: been using his htmstrip for years, love it.

All the best,
Bjorn Simonsen
 
2. I'm interested in knowing what text editor does a "replace tabs with
spaces" operation? NoteTab, Visual SlickEdit (payware), Editor2,
NoteXPad, ... of all the ones I have on my system, none have this option,
unless it's "replace tab with x spaces", which does no good as some lines
may have 2 spaces, some may have 100.


my Barry's Emacs does a replace-tab-with-appropriate-number-of-spaces.

do you really want to replace tabs with spaces, or do you just want to
delete all whitespace at the end of the line and then pad with spaces to a
particular column?

what about tabs thate are not at the end of the line?

if you don't find another solution i can write a small emacs function to do
whatever it is you want here, but you'd need to install Barry's Emacs...


jack
on a clear disk you can seek forever
 
jack put pen to paper and... uhh.. put fingers to keyboard and typed:
my Barry's Emacs does a replace-tab-with-appropriate-number-of-spaces.


do you really want to replace tabs with spaces, or do you just want to
delete all whitespace at the end of the line and then pad with spaces
to a particular column?

what about tabs thate are not at the end of the line?

if you don't find another solution i can write a small emacs function
to do whatever it is you want here, but you'd need to install Barry's
Emacs...


jack
on a clear disk you can seek forever

Jack -

What I need is a file with fixed-length records. Some, if not all records
will need to be padded with blanks (spaces) to achieve the proper length.

Replacing a tab with spaces might work, but I'd (probably) have to make
multiple passes. The situation that caused this request needs 161-byte
records. Some of the records have less than 20 characters, thus I'd need
to insert 140-something spaces. Ugh.

What I'd like is a program to prompt me for the required record length and
the end-of-record delimiter (e.g., CR, CR/LF, etc).

Doesn't seem to be anything like that "out there."

Dave
 
Dave said:
What I need is a file with fixed-length records. Some, if not all
records will need to be padded with blanks (spaces) to achieve the
proper length.

Replacing a tab with spaces might work, but I'd (probably) have to
make multiple passes. The situation that caused this request needs
161-byte records. Some of the records have less than 20 characters,
thus I'd need to insert 140-something spaces. Ugh.

What I'd like is a program to prompt me for the required record
length and the end-of-record delimiter (e.g., CR, CR/LF, etc).

Doesn't seem to be anything like that "out there."

I really don't know what the problem is with the solution I gave.
That solution makes use of Editor2 and NoteXPad, both of which you have
already installed.
You'll have to make 2 passes, one with each editor, but what is the
problem with that?

Pass #1: In Editor2, you append a tab at the end of each record, by
means
of a search and replace operation.

Then: save the file.
reopen the file in NoteXPad.
in NoteXpad you set the tab width to 161.

Pass #2: In NoteXpad, you replace tabs with spaces

W.r.t. end-of-record delimiters:
What more choice do you need, besides CR (=UNIX) and CR/LF (=Windows)?
Both Editor2 and NoteXPad can both open and save files in both UNIX and
Windows format.
In order to change the end-of-record delimiter: just save in the other
format.

HTH
 
Sietse Fliege put pen to paper and... uhh.. put fingers to keyboard and
typed:
I really don't know what the problem is with the solution I gave.
That solution makes use of Editor2 and NoteXPad, both of which you have
already installed.
You'll have to make 2 passes, one with each editor, but what is the
problem with that?

Pass #1: In Editor2, you append a tab at the end of each record, by
means
of a search and replace operation.

Then: save the file.
reopen the file in NoteXPad.
in NoteXpad you set the tab width to 161.

Pass #2: In NoteXpad, you replace tabs with spaces

W.r.t. end-of-record delimiters:
What more choice do you need, besides CR (=UNIX) and CR/LF (=Windows)?
Both Editor2 and NoteXPad can both open and save files in both UNIX and
Windows format.
In order to change the end-of-record delimiter: just save in the other
format.

HTH

Sietse -

In the version of NoteXPad I have (1.4.1.0), the largest tab size
available (Tools, Options, Editor) is 99. Thus, I'd have to insert two
tabs in Editor2.

In the version of Editor2 I have (version 2.0, build 2.0.0.7), there's no
option to replace E-O-L with Tab,E-O-L (i.e., no "\n" to "\t\n").

I used NoteTab Light (version 4.95) to change \n to \t\n. In NoteXPad, I
changed the default tab size to 99, then chose Edit, Convert, Tabs to
Spaces. Some lines (the short ones) ended up in colunn 100, others in
column 199.

And, as far as the EOL char, you're right, it's simple to open, save as.
Given utopia, it's easier to not have to use two programs.

So... I admit that I'm not as skilled as you are, or my tools aren't
correct, or something, but I STILL can't get your solution to work
correctly.

Dave
(with a few less hairs, and the one's I have left are turning grey)
 
Back
Top