我正在尝试将大型机字帖转换为csv(仅限所有数据类型的长度),但小数位不添加。例如,假设$_r = FALSE * TRUE; // (0 * 1)
if ($_r) ? print 'TRUE' : print 'FALSE'; // prints FALSE
$_r = FALSE / TRUE; // (0 / 1)
if ($_r) ? print 'TRUE' : print 'FALSE'; // prints FALSE
$_r = TRUE / FALSE; // (1 / 0)
if ($_r) ? print 'TRUE' : print 'FALSE'; // prints Warning: **Division by zero**
有col1
。它将转换为总大小13,但预期输出应为13 + 7 = 20
S9(13)v9(7)
答案 0 :(得分:1)
如果你可以使用python以外的语言, 其他几个选项包括
e.g。在python中加载由cb2xml生成的xml
tree = ET.parse('cbl2xml_Test110.cbl.xml')
以下程序将打印Cobol copybok属性变为:
## Get an attribute if it exist otherwise return ''
def getAttr(d, key):
r=''
if key in d.attrib:
r = d.attrib[key]
return r
# Get attribute if it exists
def getAttrId(d, key):
r=''
if key in d.attrib:
r = key + '=' + d.attrib[key]
return r
##########################################################################
# Purpose: Print one item
##########################################################################
def printItem(indent, item):
n = indent + item.attrib['level'] + " " + item.attrib['name'] + " "
n = n[:50]
print n, '\t', item.attrib['position'], '\t', item.attrib['storage-length'], '\t', getAttr(item, 'display-length'), getAttr(item, 'picture'), getAttrId(item, 'usage'), getAttrId(item, 'numeric'), getAttrId(item, 'signed')
for child in item.findall('item'):
printItem(indent + " ", child)
#########################################################################
tree = ET.parse('cbl2xml_Test110.cbl.xml')
root = tree.getroot()
print ">> ", root.tag, root.attrib['filename']
for child in root.findall('item'):
printItem(" ", child)
使用过其他语言的cb2xml的人的一些例子
注意:我写过JRecord并维护cb2xml