Have filter-regs emit a special value "-COMPUTED-" for filtered data values,
rather than blanking them out entirely. This lets csv-to-json.py handle the case where an earlier input file has (e.g.) a registration value which does not match the computed value, and then a later input file has a value that does match. In this case we want to override the older value with the newer value, then notice that the registration can be omitted when writing the database. Previously in this case the older (incorrect) value would be used.
This commit is contained in:
parent
0d2bd6ae34
commit
35299c47ba
2 changed files with 24 additions and 7 deletions
tools
|
@ -37,6 +37,16 @@ def readcsv(name, infile, blocks):
|
|||
|
||||
print >>sys.stderr, 'Read', ac_count, 'aircraft from', name
|
||||
|
||||
def cleandb(blocks):
|
||||
for blockdata in blocks.values():
|
||||
for dkey in list(blockdata.keys()):
|
||||
block = blockdata[dkey]
|
||||
for key in list(block.keys()):
|
||||
if block[key] == '-COMPUTED-':
|
||||
del block[key]
|
||||
if len(block) == 0:
|
||||
del blockdata[dkey]
|
||||
|
||||
def writedb(blocks, todir, blocklimit, debug):
|
||||
block_count = 0
|
||||
|
||||
|
@ -110,5 +120,6 @@ if __name__ == '__main__':
|
|||
with closing(open(filename, 'r')) as infile:
|
||||
readcsv(filename, infile, blocks)
|
||||
|
||||
cleandb(blocks)
|
||||
writedb(blocks, sys.argv[-1], 2500, False)
|
||||
sys.exit(0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue