我正在使用模块pypxlib从Paradox数据库文件(.DB)读取数据文件。
在阅读每一行时,我写了一个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
答案 0 :(得分:1)
Paradox表包含几种数字类型,包括' Number' (64位浮点数),'长整数' (32位有符号整数)和' Short' (16位有符号整数)。这些类型中的每一种都具有指定用于表示“空白”的带内值。区别于零。这些是您期望的值“无”#。
。当pxlib库和pypxlib包装器将Paradox数据转换为Python数据类型时,'空白'的带内值转换为1,然后是所有0。在二进制补码表示法中,这是在正方向和负方向上距离零最远的值。
如果BDE类型是' Long Integer'那么这确实表示为-2147483648。