I have the following three values in a CSV file: 1683199814 2087175640 1348771152 I need to write them into a flat file using a python program, which will be loaded into Mainframe DB2 using a COBOL program. The copybook says that it is of type PIC S9(09) COMP. This will be loaded into a DB2 table of type INTEGER of DB2 length 4. Below is the python code logic that I used to convert this: record = bytearray() record.extend(struct.pack('>i', member_id)) Where member_id has the values from the CSV file through which I am iterating. I then write this record out into the file which they load into the DB2 table. However, after loading, the mainframe engineer showed me that the values are completely different and sometimes negative. He mentioned that mainframe is using Big Endian for that value. The values are showing differently as below: -2065547322 1334273920 -679209769 I don't know what I am doing wrong! Continue reading...