MCPcopy Create free account
hub / github.com/comaps/comaps / make_tsv

Function make_tsv

tools/python/opentable_restaurants.py:82–94  ·  view source on GitHub ↗
(data_file, output_file)

Source from the content-addressed store, hash-verified

80
81
82def make_tsv(data_file, output_file):
83 for rest in data_file:
84 rest = json.loads(rest)
85 try:
86 address = ' '.join([rest['address'], rest['city'], rest['country']])
87 # Some addresses contain \t and maybe other spaces.
88 address = re.sub(r'\s', ' ', address)
89 except TypeError:
90 address = ''
91 row = '\t'.join(map(unicode, [rest['rid'], rest['latitude'], rest['longitude'],
92 rest['name'], address, rest['reservation_url'],
93 rest['phone_number']]))
94 print(row.encode('utf-8'), file=output_file)
95
96
97if __name__ == '__main__':

Callers 1

Calls 3

mapFunction · 0.85
joinMethod · 0.45
subMethod · 0.45

Tested by

no test coverage detected