pythonpython-2.7paradox

Python 'None' value appearing as -2147483648


I'm reading in a data file from a Paradox database file (.DB) using a module pypxlib.

Whilst reading each row, I write to a CSV.

For some reason, values which expected to be 'None' are appearing as the number -2147483648.

Does anyone know the significance of this number? Why would this error be appearing?

Code below:

for idx in range(0,len(matches)): #for each file found
  print "processing %s" % matches[idx]['file']
  #outputfile = path.join('./output/' + form_file_name(dbfile) + '.csv')
  try:
    myTable = Table(matches[idx]['file']) #class from pypxlib that takes a filepath
    cols = []                             #and creates a 'table' that can be read
    for col in myTable.fields: #gets fields from the table
        cols.append(col)
    pTable = []

    with open(output_folder +"/myoutput_" + matches[idx]['f'] + ".csv", "wb") as f:
        writer = csv.writer(f)
        writer.writerow(cols)
        rowcount = 0
        for row in myTable: # for every row in table
            myRow = []
            for fld in cols: # for every cell in the row
                myRow.append(row[fld]) #append cell to the row
            writer.writerow(myRow) #then write the row to the csv
            rowcount = rowcount + 1
            if rowcount >= 100:
                break #just testing on the first 1000 records

Solution

  • Paradox tables contain several numeric types including 'Number' (64-bit floating point), 'Long Integer' (32-bit signed integer), and 'Short' (16-bit signed integer). Each of these types has an in-band value designated to represent 'blank' as distinguished from zero. These are the values that you are expecting to be 'None'.

    When the pxlib library and pypxlib wrapper convert Paradox data to Python data types, the in-band value for 'blank' translates to a 1 followed by all 0's. In two's-complement notation this is the value that is furthest from zero in both the positive and negative direction.

    If the BDE type was 'Long Integer' then this is indeed represented as -2147483648.