ftp return format

aflinsch avflinsch at att.net
Fri May 5 15:13:59 EDT 2000


Richard Chamberlain wrote:
> 
> 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...



More information about the Python-list mailing list