Python“None”值显示为2147483648

2024-03-28 23:12:34 发布

您现在位置:Python中文网/ 问答频道 /正文

使用pxi模块从pxi数据库文件(.Paradox)读取数据。在

在读每一行的时候,我写一个CSV。在

由于某些原因,预期为“无”的值显示为数字-2147483648。在

有人知道这个数字的意义吗?为什么会出现这个错误?在

代码如下:

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

Tags: csvtheinformytabletablefilewriter
1条回答
网友
1楼 · 发布于 2024-03-28 23:12:34

Paradox表包含几种数字类型,包括“Number”(64位浮点)、“Long Integer”(32位带符号整数)和“Short”(16位有符号整数)。这些类型中的每一种都有一个带内值,用于表示与零不同的“空白”。这些值应该是“None”。在

当pxlib库和pypxlib包装器将Paradox数据转换为Python数据类型时,“blank”的带内值将转换为1,后跟所有0。在two's补码表示法中,这是正方向和负方向上离零最远的值。在

如果这是648型的整数,那么它就代表了648。在

相关问题 更多 >