× 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: Scott Klement <klemscot@xxxxxxxxxxxx>
  • Date: Tue, 31 Jul 2001 09:55:52 -0500 (CDT)


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
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.