[Novalug] Reading a fixed length text file with no record separator

William Sutton william@trilug.org
Tue Oct 25 13:45:22 EDT 2016


There *are* Windows-compiled UNIX utilities, some even for running in the 
DOS command prompt.  Presence of such does not imply the existence of 
Perl, Python, or even the ability to install them, especially in a 
corporate environment (where security may have locked that access down).

When a user asks for help with UNIX utilities on Windows, I don't assume 
they're asking for PowerShell help.

But if they do, even on this list, I may just help.  Because, as the great 
Mark Spencer of Digium fame once told me, Open Source is about helping 
people.  And sometimes that means helping with MicroSoft-y stuff.

As opposed to saying "not my problem" and walking away.

Because if we help, next time they might think better of Open Source.  If 
we don't, it adds to a (sometimes well-deserved) reputation for elitism 
and snobbishness.  And we don't want that, do we? ;-)

William Sutton

On Tue, 25 Oct 2016, James Ewing Cottrell III wrote:

> Both Perl and Python have Installers for Window available.
>
> If you don't have those available, you aew unlikely to have DD, or FOLD, or 
> the BASH features I mentioned.
>
> Elitist or not, we are unlikely to be able to provide advice on PowerShell or 
> Visual Basic solutions.
>
> Copy the file to Linux, transform it, and copy it back.
>
> Or export the Share, mount it on Linux, and Transform it In Place.
>
> JIM
>
> On 10/23/2016 1:14 PM, William Sutton wrote:
>> The original statement of the problem included
>> 
>> "I am on a Windows 7 machine, but I have awk, dd, and a few other unix
>> tools ported to Windows available."
>> 
>> I agree with John Kennedy's response earlier today.
>> 
>> William Sutton
>> 
>> On Sun, 23 Oct 2016, jerry w wrote:
>> 
>>> 
>>> Cygwin available?
>>> POSIX capable?
>>> 
>>> Now consider most kids are in m$ only environments, without even admin.
>>> 
>>> Around here , no printing either, so even resumes, long papers you
>>> need to
>>> edit: nope...  Photocopy/printing/Fax?:staff only. Goto FedEx, Kinkos,
>>> etc.
>>> 
>>> Try asking a Linux question on a m$ list...
>>> 
>>> 
>>> On Sun, Oct 23, 2016, 07:15 William Sutton <william@trilug.org> wrote:
>>>       Nice way to discourage someone asking questions in the future,
>>>       too.
>>>       "We're a bunch of elitists.  If your question doesn't fit our
>>>       definition
>>>       of 'acceptable', we don't want you."
>>>
>>>       Sometimes people need to be more pragmatic.  If the person has
>>>       UNIX
>>>       utilities on Windows, I think it's fair to let them ask.
>>>
>>>       William Sutton
>>>
>>>       On Sun, 23 Oct 2016, jerry w wrote:
>>>
>>>       >
>>>       > Flawed spec: WinBlow$ on a Linux list...
>>>       >
>>>       >
>>>       > On Thu, Oct 20, 2016, 16:31 William Sutton via Novalug
>>>       > <novalug@firemountain.net> wrote:
>>>       >       Except he didn't have Perl.
>>>       >
>>>       >       William Sutton
>>>       >
>>>       >       On Thu, 20 Oct 2016, James Ewing Cottrell III via
>>>       Novalug wrote:
>>>       >
>>>       >       > I think we have a winner here, but be aware that this
>>>       command
>>>       >       will nuke
>>>       >       > trailing spaces, so each line will not be 184
>>>       characters. I'd
>>>       >       say this is
>>>       >       > mostly what you want, but I'd call it a flaw in DD's
>>>       >       conversion offerings.
>>>       >       >
>>>       >       > Actually, Rich didn't add a CR, but that's easy to do
>>>       by
>>>       >       piping to
>>>       >       >
>>>       >       >       sed 's/$/\r/'
>>>       >       >
>>>       >       > or maybe dos2unix. Why a CR is desired is a mystery,
>>>       but since
>>>       >       it's part of
>>>       >       > the Specs, we must honor it.
>>>       >       >
>>>       >       > I played around with trying to use READ and ECHO,
>>>       something
>>>       >       like
>>>       >       >
>>>       >       >       tr -d \\012 < /etc/passwd |
>>>       >       >       sed 's/ /  /g' |
>>>       >       >       while IFS= read -N20 x; do echo "$x"; done |
>>>       >       >       cat -vet | less
>>>       >       >
>>>       >       > And that DID give me what I wanted, including the
>>>       Trailing
>>>       >       Spaces.
>>>       >       >
>>>       >       > Ultimately tho, trying to shoehorn the existing
>>>       GNUtilities,
>>>       >       while
>>>       >       > instructive, probably takes way longer than writing a
>>>       simple
>>>       >       filter:
>>>       >       >
>>>       >       >       perl -e 'print "$x\r\n" while
>>>       sysread(STDIN,$x,182)'"
>>>       >       >
>>>       >       > JIM
>>>       >       >
>>>       >       > On 10/17/2016 4:51 PM, Rich Kulawiec via Novalug
>>>       wrote:
>>>       >       >> On Mon, Oct 17, 2016 at 08:19:08PM +0000, Ide, Jim J.
>>>       - US
>>>       >       via Novalug
>>>       >       >> wrote:
>>>       >       >>> I have a very large text file that contains fixed
>>>       length
>>>       >       records (each
>>>       >       >>> record is 182 characters).
>>>       >       >>> There is no record separator character at the end of
>>>       each
>>>       >       record (no \n).
>>>       >       >>> Starting at the first character of this file, I want
>>>       to read
>>>       >       182
>>>       >       >>> characters,
>>>       >       >>> write those 182 characters to an output file with
>>>       CRLF
>>>       >       appended,
>>>       >       >>> read the next 182 character, write them to the
>>>       output file
>>>       >       with CRLF
>>>       >       >>> appended,
>>>       >       >>> and so on, until the end of input file.
>>>       >       >>
>>>       >       >>      dd if=inputfile of=outputfile cbs=182
>>>       conv=unblock
>>>       >       >>
>>>       >       >> ---rsk
>>>       >       >>
>>>       >
>>>
>>>  **********************************************************************
>>>       >       >> The Novalug mailing list is hosted by
>>>       firemountain.net.
>>>       >       >>
>>>       >       >> To unsubscribe or change delivery options:
>>>       >       >> http://www.firemountain.net/mailman/listinfo/novalug
>>>       >       >>
>>>       >       >
>>>       >
>>>
>>>  **********************************************************************
>>>       >       > The Novalug mailing list is hosted by
>>>       firemountain.net.
>>>       >       >
>>>       >       > To unsubscribe or change delivery options:
>>>       >       > http://www.firemountain.net/mailman/listinfo/novalug
>>>       >       >
>>>       >
>>>
>>>  **********************************************************************
>>>       >       The Novalug mailing list is hosted by firemountain.net.
>>>       >
>>>       >       To unsubscribe or change delivery options:
>>>       >       http://www.firemountain.net/mailman/listinfo/novalug
>>>       >
>>>       >
>>>       >
>>> 
>>> 
>>> 
>



More information about the Novalug mailing list