google-research
41 строка · 1.2 Кб
1# coding=utf-8
2# Copyright 2024 The Google Research Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16#!/usr/bin/python
17r"""Combine the stats dictionaries from a bunch of graphml files into a csv.
18
19Usage:
20./stats_to_csv.py --output=weighted/stats.csv weighted/*.graphml
21"""
22
23from absl import app
24from absl import flags
25from graph_sampler import graph_io
26import pandas as pd
27
28FLAGS = flags.FLAGS
29flags.DEFINE_string('output', None, 'Path to output csv file.')
30
31
32def main(argv):
33filenames = argv[1:]
34stats_list = [graph_io.get_stats(filename) for filename in filenames]
35df = pd.DataFrame(stats_list, index=pd.Index(filenames, name='filename'))
36df.to_csv(FLAGS.output)
37
38
39if __name__ == '__main__':
40flags.mark_flag_as_required('output')
41app.run(main)
42