ftp return format 
Author Message
 ftp return format

Hi,

Although its not directly a python question, I know you guys are probably
nice enough to answer it anyway ;)

At work we run ftp to get files off an AS400 into a text file. These then
get imported into Excel to mess around with.

I would like to be able to use Python's ftplib to get the file and then use
COM to import straight into Excel.

The problem is then when I use ftplib I get the data back in a certain
format, I've also used the dos ftp command and I get the data the same way.

We use a thing called Rumba FileTransfer which is obviously translating
somehow, anyone know how I can do the same?

e.g.

from python:

0183
0000100000000000000000000000000000000000K0000000000000K
0184
0000300000013200000000000000000000000000000000013200000
0185
0000300001185200000000000000006M0000000000000118520006M

from Rumba:

0183                               1            0         0
0        -2         0    -2
0184                               3        132         0        0        0
132     0
0185                               3    11852         0    -64        0
11852   -64

I realise that it's fix delimited, but then I get stuck on the K and M which
crop up with negative numbers.

Thanks,

Richard



Tue, 22 Oct 2002 03:00:00 GMT  
 ftp return format
Okay, probably a dumb question but could it be that the transfer should be set
to binary mode and is using the default ascii mode?
Quote:

> Hi,

> Although its not directly a Python question, I know you guys are probably
> nice enough to answer it anyway ;)

> At work we run ftp to get files off an AS400 into a text file. These then
> get imported into Excel to mess around with.

> I would like to be able to use Python's ftplib to get the file and then use
> COM to import straight into Excel.

> The problem is then when I use ftplib I get the data back in a certain
> format, I've also used the dos ftp command and I get the data the same way.

> We use a thing called Rumba FileTransfer which is obviously translating
> somehow, anyone know how I can do the same?

> e.g.

> from python:

> 0183
> 0000100000000000000000000000000000000000K0000000000000K
> 0184
> 0000300000013200000000000000000000000000000000013200000
> 0185
> 0000300001185200000000000000006M0000000000000118520006M

> from Rumba:

> 0183                               1            0         0
> 0        -2         0    -2
> 0184                               3        132         0        0        0
> 132     0
> 0185                               3    11852         0    -64        0
> 11852   -64

> I realise that it's fix delimited, but then I get stuck on the K and M which
> crop up with negative numbers.

> Thanks,

> Richard



Tue, 22 Oct 2002 03:00:00 GMT  
 ftp return format


Quote:
> We use a thing called Rumba FileTransfer which is obviously
translating
> somehow, anyone know how I can do the same?

> e.g.

> from python:

> 0183
> 0000100000000000000000000000000000000000K0000000000000K
> 0184
> 0000300000013200000000000000000000000000000000013200000
> 0185
> 0000300001185200000000000000006M0000000000000118520006M

> from Rumba:

> 0183                               1            0         0
> 0        -2         0    -2
> 0184                               3        132         0
0        0
> 132     0
> 0185                               3    11852         0    -64
0
> 11852   -64

> I realise that it's fix delimited, but then I get stuck on the K and
M which
> crop up with negative numbers.

Richard,

These appear to be overpunched characters (a remnant of cardpunch
entry) and the characters directly translate into digits, with the
implication that the entire numeric field carries a negative sign.

If you isolate the field, Translate '}' to '0', J-R to 1-9
respectively, and multiply its numeric value by -1, you'll get the
correct effect. It's likely that someone has already had to do this,
but I haven't (in Python, anyway). Pretty trivial, though.

--
Pythons, unlike some other snakes, do have hindlimbs, but they never
develop beyond vestigial stumps. The arrest of limb development is
due to a failure of the sonic hedgehog signalling system ...

Sent via Deja.com http://www.deja.com/
Before you buy.



Tue, 22 Oct 2002 03:00:00 GMT  
 ftp return format

Quote:

> Okay, probably a dumb question but could it be that the transfer should be set
> to binary mode and is using the default ascii mode?

Or vice versa, having done something similar in a past life.  If the
FTP server is an AS/400, I assume it uses EBCDIC.  If the file
transfer is done in ASCII mode, it's the FTP server's responsibility
to translate to EBCDIC (the relevant RFC says transfers are in ASCII,
with no provision for different character sets); if it's in binary
mode, you'll get the original EBCDIC data which will be difficult to
deal with on a PC/Unix system.  So, maybe you're *not* in ASCII mode.

--
A.M. Kuchling                   http://starship.python.net/crew/amk/
Destiny is the oldest of the Endless; in the beginning was the Word, and it
was traced by hand on the first page of his book, before ever it was spoken
aloud.
  -- From SANDMAN: "Season of Mists", episode 0



Tue, 22 Oct 2002 03:00:00 GMT  
 ftp return format

Quote:

> Hi,

> Although its not directly a Python question, I know you guys are probably
> nice enough to answer it anyway ;)

> At work we run ftp to get files off an AS400 into a text file. These then
> get imported into Excel to mess around with.

> I would like to be able to use Python's ftplib to get the file and then use
> COM to import straight into Excel.

> The problem is then when I use ftplib I get the data back in a certain
> format, I've also used the dos ftp command and I get the data the same way.

> We use a thing called Rumba FileTransfer which is obviously translating
> somehow, anyone know how I can do the same?

> e.g.

> from python:

> 0183
> 0000100000000000000000000000000000000000K0000000000000K
> 0184
> 0000300000013200000000000000000000000000000000013200000
> 0185
> 0000300001185200000000000000006M0000000000000118520006M

> from Rumba:

> 0183                               1            0         0
> 0        -2         0    -2
> 0184                               3        132         0        0        0
> 132     0
> 0185                               3    11852         0    -64        0
> 11852   -64

> I realise that it's fix delimited, but then I get stuck on the K and M which
> crop up with negative numbers.

It's IBM's infamous Zoned Decimal format.
The final digit of the number is overpunched, a hold over from the old
card punch days.

The translation is as follows (assume a 3 digit number for the
examples)

for negative numbers
-010=01} (there is a negative zero, sort of...)
-009=00R
-008=00Q
-007=00P
-006=00O
-005=00N
-004=00M
-003=00L
-002=00K
-001=00J

for positive signed numbers, the format is
+001=00A
+002=00B
+003=00C
+004=00D
+005=00E  
+006=00F
+007=00G
+008=00H
+009=00I
+010=01{ (and a positive zero of course)

For unsigned numbers, no overpunch is done, and the translation from
ebcdic to ascii works as normal.

The whole concept is sort of wacky, and looks odd even when viewed in
ebcdic, mostly since characters other than letters show up in the
middle of the alphabet...



Tue, 22 Oct 2002 03:00:00 GMT  
 ftp return format

Quote:

> The problem is then when I use ftplib I get the data back in a certain
> format, I've also used the dos ftp command and I get the data the same way.

> We use a thing called Rumba FileTransfer which is obviously translating
> somehow, anyone know how I can do the same?

Rumba is probably using the AS/400 database host servers.   This gives
it access to the database fields, which it can write out using fixed
field widths in PC format.

The equivalent from Python would be to use ODBC, ADODB or the record
level access available from COM in the free parts of IBM Client
Access.  ODBC works quite well for me whenever I need to get data from
our AS/400.

--
         Carey Evans  http://home.clear.net.nz/pages/c.evans/

CONFIG_IPL_RDR
  Select this option if you want to IPL the image from a real card reader.



Thu, 24 Oct 2002 03:00:00 GMT  
 ftp return format
OK that sounds about right - I installed the Client Access ODBC drivers and
was able to return correct data.

Is there anyway I can do this without having to install Client Access and an
ODBC driver on each client?

Thanks (again :) ),

Richard


Quote:

> > The problem is then when I use ftplib I get the data back in a certain
> > format, I've also used the dos ftp command and I get the data the same
way.

> > We use a thing called Rumba FileTransfer which is obviously translating
> > somehow, anyone know how I can do the same?

> Rumba is probably using the AS/400 database host servers.   This gives
> it access to the database fields, which it can write out using fixed
> field widths in PC format.

> The equivalent from Python would be to use ODBC, ADODB or the record
> level access available from COM in the free parts of IBM Client
> Access.  ODBC works quite well for me whenever I need to get data from
> our AS/400.

> --
> Carey Evans  http://home.clear.net.nz/pages/c.evans/

> CONFIG_IPL_RDR
>   Select this option if you want to IPL the image from a real card reader.



Fri, 25 Oct 2002 03:00:00 GMT  
 ftp return format

Quote:

> OK that sounds about right - I installed the Client Access ODBC drivers and
> was able to return correct data.

> Is there anyway I can do this without having to install Client Access and an
> ODBC driver on each client?

Hmm, where I work it's getting Python installed that's the problem.  ;)

Here's a few ideas, not all of them particularly helpful:

  Parse the data as the other posts suggested, including the
   }JKLMNOPQR sign character, and hope you don't get any packed
   decimal in the future.

  FTP the data in binary, so you don't have to worry about the
   EBCDIC -> ASCII conversion making things more confusing.  I posted
   a couple of functions here a few weeks ago to help with this.

  Get the Client Access Express manuals and RedBook (all available
   for download as PDFs) and automate the ODBC install so that you
   don't have to click on half a dozen dialog boxes to install it.

  Use CPYTOIMPF on the AS/400 to copy the data into a different
   format in a stream file, then use FTP or NetServer to download this
   file.  You can submit remote commands over an AS/400 FTP session,
   so you could do this on request from the Python program.

  Write a program on the AS/400 that will return the data in a
   useful format when you connect to it over TCP/IP.

  Run the program under JPython and use the AS/400 Toolkit for Java
   classes to connect to the AS/400 (this works, I've tried it).

  Download the Java source for the Toolkit for Java and port it to
   Python.  :)  This would be a rather large job...

--
         Carey Evans  http://home.clear.net.nz/pages/c.evans/

              "I'm leaning towards blind panic myself."



Sun, 27 Oct 2002 03:00:00 GMT  
 ftp return format
Thanks for the info,

Suddenly installing client access sounds much easier ;)

Richard

Quote:

> > OK that sounds about right - I installed the Client Access ODBC drivers
and
> > was able to return correct data.

> > Is there anyway I can do this without having to install Client Access
and an
> > ODBC driver on each client?

> Hmm, where I work it's getting Python installed that's the problem.  ;)

> Here's a few ideas, not all of them particularly helpful:

>   Parse the data as the other posts suggested, including the
>    }JKLMNOPQR sign character, and hope you don't get any packed
>    decimal in the future.

>   FTP the data in binary, so you don't have to worry about the
>    EBCDIC -> ASCII conversion making things more confusing.  I posted
>    a couple of functions here a few weeks ago to help with this.

>   Get the Client Access Express manuals and RedBook (all available
>    for download as PDFs) and automate the ODBC install so that you
>    don't have to click on half a dozen dialog boxes to install it.

>   Use CPYTOIMPF on the AS/400 to copy the data into a different
>    format in a stream file, then use FTP or NetServer to download this
>    file.  You can submit remote commands over an AS/400 FTP session,
>    so you could do this on request from the Python program.

>   Write a program on the AS/400 that will return the data in a
>    useful format when you connect to it over TCP/IP.

>   Run the program under JPython and use the AS/400 Toolkit for Java
>    classes to connect to the AS/400 (this works, I've tried it).

>   Download the Java source for the Toolkit for Java and port it to
>    Python.  :)  This would be a rather large job...

> --
> Carey Evans  http://home.clear.net.nz/pages/c.evans/

>               "I'm leaning towards blind panic myself."



Sun, 27 Oct 2002 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Return-code after calling ftp from rexx

2. Squeak FTP site established: ftp://ftp.create.ucsb.edu/pub/Smalltalk/Squeak

3. My ftp site (ftp://ftp.iag.net/pub/clipper)

4. Format For FTP Files

5. V format ftp to non-IBM system

6. V format ftp to non-IBM system

7. .Z Format in FTP servers?

8. .Z Format in FTP servers?

9. FTP and MF neg signed numbers in disp format

10. fstsw (ax) return format?

11. Supress carriage return in Format

12. Clock format returns unexpected value

 

 
Powered by phpBB® Forum Software