× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: RE: Ascii file from FTP
  • From: "JIM LANGSTON" <JLANGSTON@xxxxxxxxxxx>
  • Date: Tue, 31 Jul 2001 08:23:28 -0700
  • Importance: Normal

One thing I've done at various times is do it manually.  If your data
doesn't contain any double spaces it is much easier.

I would first do a change from '           ' to '<TAB>' for all.
Then I would change '          ' to '<TAB>' for all (one space less).
and keep going down til I got to '  ' to '<TAB>' for all.  (Notice: 2
spaces)
This would take any white space and make them <TAB>s.  so at the end, this:
FieldA      12345.00     Field B         Some Comment Here
would become this:
FieldA<TAB>12345.00<TAB>Field B<TAB>Some Comment Here

I haven't had to do it enough to bother to write a program for it though.

Regards,

Jim Langston

-----Original Message-----
From: owner-midrange-l@midrange.com
[mailto:owner-midrange-l@midrange.com]On Behalf Of Scott Klement
Sent: Tuesday, July 31, 2001 7:56 AM
To: MIDRANGE-L@midrange.com
Subject: Re: Ascii file from FTP



On Tue, 31 Jul 2001, Emanuele Salvador wrote:
>
> I need to convert on my Linux box some ASCII files retrieved with FTP
> from an AS400 from fixed width to tab delimited text.
> Has anybody some experience with sed or awk to do so? Or is there a way
> (aside from CA transfer) to accomplish this task?
> Thanks in advance and excuse my poor english,
>
>
> Emanuele Salvador
> Consorzio Florida Servizi

One easy way:

Instead of trying to convert it on the Linux side, it'd be easier to
run the CPYTOIMPF command on the AS/400 first, then download the
result of that.

CPYTOIMPF can be used to transform the file into a tab-delimited file
prior to download.

Another easy way:

You could get the 'asdbget' program which was written as part of the
Linux tn5250 project.   It will download an AS/400 file and convert it
to XML.  Then, a perl script can convert it from XML to tab-delimited.

You'd need to get tn5250 & the asdbget program from
tn5250.sourceforge.net, and the asdbget program may only be available
from the CVS repo...    If this option interests you, join the Linux5250
list here at Midrange.com, and I'll help you there :)


The hard way:

If you really want to do it on the Linux side, you'd need to know the
start and end positions of each field, and substring them out, then
write them as tab delimited.

If you had any fields that were defined as 'packed' or 'binary' on
the AS/400, the conversion from EBCDIC to ASCII may have corrupted
them.   If this is the case, you'd need to download them from the
AS/400 in BINARY mode, and then convert each field to an appropriate
text representation before converting it to ASCII.

This would require some fairly serious programming, awk or sed would
not be able to handle it.



+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator:
david@midrange.com
+---

+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.