Created
August 6, 2019 16:31
-
-
Save Ninpo/601453b156efa40114567f3d32a2c0e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: from itertools import chain, repeat, islice | |
...: | |
...: def pad_infinite(iterable, padding=None): | |
...: return chain(iterable, repeat(padding)) | |
...: | |
...: def pad(iterable, size, padding=None): | |
...: return islice(pad_infinite(iterable, padding), size) | |
...: | |
In [2]: from collections import defaultdict | |
In [3]: import pandas as pd | |
In [4]: mb_funcs = defaultdict(list) | |
In [5]: with open("new-mb-funcs.txt", "r") as new_mb_funcs: | |
...: for line in new_mb_funcs: | |
...: mb_funcs[line.split()[-1].rstrip('(')].append(line.split()[1]) | |
In [7]: for key in mb_funcs.keys(): | |
...: mb_funcs[key] = list(pad(mb_funcs[key], 150, padding='')) | |
In [8]: df = pd.DataFrame(mb_funcs) | |
In [9]: df.to_csv("mb_func_locations.csv", index=None, header=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment