In [2]:
import pandas as pd
import py2neo

In [77]:
content = ""
with open (r"C:\Temp\famix\buschmais_spring_petclinic_joa.mse") as f:
    content = f.read()
    content = content[1:-2]
    content = content.replace("\n\t\t", "")
    content = content.replace("\n", "")
    content = content.replace(")))", ")))\n")
    content = content.replace("^\t","",)
    #content = content[1:-2]
    

with open(
    r"C:\Temp\famix\buschmais_spring_petclinic_joa.txt",
    mode='w') as f:
    
    f.write(content)
    
from io import StringIO

mse = pd.read_csv(
    StringIO(content),
    header=None,
    sep="\n",
    names=['raw'])

mse.raw = mse.raw.str.replace('""', '\"')
mse.loc[
    mse[(mse.raw.str.startswith('"')) & (mse.raw.str.endswith('"'))],
    'raw'] = mse.raw.str[1:-2]

mse = mse[mse["raw"].str.startswith("\t(FAMIX.")]
mse


Out[77]:
raw
0 \t(FAMIX.Access (id: 1)(accessor (ref: 471))(s...
1 \t(FAMIX.Invocation (id: 2)(candidates (ref: 2...
2 \t(FAMIX.AnnotationInstanceAttribute (id: 3)(a...
3 \t(FAMIX.IndexedFileAnchor (id: 7)(element (re...
4 \t(FAMIX.Inheritance (id: 9)(subclass (ref: 60...
5 \t(FAMIX.IndexedFileAnchor (id: 10)(element (r...
6 \t(FAMIX.Invocation (id: 13)(candidates (ref: ...
7 \t(FAMIX.IndexedFileAnchor (id: 14)(element (r...
8 \t(FAMIX.IndexedFileAnchor (id: 20)(element (r...
9 \t(FAMIX.Invocation (id: 23)(candidates (ref: ...
10 \t(FAMIX.AnnotationInstanceAttribute (id: 24)(...
11 \t(FAMIX.IndexedFileAnchor (id: 27)(element (r...
12 \t(FAMIX.DeclaredException (id: 29)(definingMe...
13 \t(FAMIX.Access (id: 30)(accessor (ref: 2239))...
14 \t(FAMIX.IndexedFileAnchor (id: 31)(element (r...
15 \t(FAMIX.IndexedFileAnchor (id: 34)(element (r...
16 \t(FAMIX.AnnotationInstanceAttribute (id: 36)(...
17 \t(FAMIX.Access (id: 40)(accessor (ref: 3580))...
18 \t(FAMIX.AnnotationInstance (id: 41)(annotated...
19 \t(FAMIX.ParameterizableClass (id: 42)(name 'E...
20 \t(FAMIX.ParameterizedType (id: 44)(name 'Map<...
21 \t(FAMIX.AnnotationInstanceAttribute (id: 45)(...
22 \t(FAMIX.Inheritance (id: 50)(subclass (ref: 6...
23 \t(FAMIX.IndexedFileAnchor (id: 51)(element (r...
24 \t(FAMIX.Invocation (id: 53)(candidates (ref: ...
25 \t(FAMIX.Inheritance (id: 54)(subclass (ref: 6...
26 \t(FAMIX.Invocation (id: 55)(candidates (ref: ...
27 \t(FAMIX.IndexedFileAnchor (id: 56)(element (r...
28 \t(FAMIX.Access (id: 59)(accessor (ref: 496))(...
29 \t(FAMIX.AnnotationTypeAttribute (id: 60)(name...
... ...
3485 \t(FAMIX.Method (id: 6947)(name 'intValue')(cy...
3486 \t(FAMIX.Invocation (id: 6950)(candidates (ref...
3488 \t(FAMIX.Method (id: 6951)(name 'toString')(cy...
3489 \t(FAMIX.IndexedFileAnchor (id: 6953)(element ...
3490 \t(FAMIX.Invocation (id: 6956)(candidates (ref...
3491 \t(FAMIX.DeclaredException (id: 6957)(defining...
3492 \t(FAMIX.IndexedFileAnchor (id: 6958)(element ...
3493 \t(FAMIX.IndexedFileAnchor (id: 6960)(element ...
3494 \t(FAMIX.ParameterizedType (id: 6964)(name 'Ab...
3495 \t(FAMIX.Inheritance (id: 6965)(subclass (ref:...
3496 \t(FAMIX.AnnotationInstanceAttribute (id: 6966...
3497 \t(FAMIX.IndexedFileAnchor (id: 6968)(element ...
3498 \t(FAMIX.IndexedFileAnchor (id: 6975)(element ...
3499 \t(FAMIX.IndexedFileAnchor (id: 6977)(element ...
3500 \t(FAMIX.Access (id: 6979)(accessor (ref: 2170...
3501 \t(FAMIX.IndexedFileAnchor (id: 6980)(element ...
3502 \t(FAMIX.Access (id: 6982)(accessor (ref: 2391...
3503 \t(FAMIX.IndexedFileAnchor (id: 6983)(element ...
3504 \t(FAMIX.Access (id: 6985)(accessor (ref: 2228...
3505 \t(FAMIX.LocalVariable (id: 6986)(name 'webApp...
3506 \t(FAMIX.IndexedFileAnchor (id: 6987)(element ...
3507 \t(FAMIX.IndexedFileAnchor (id: 6989)(element ...
3508 \t(FAMIX.IndexedFileAnchor (id: 6991)(element ...
3509 \t(FAMIX.Access (id: 6996)(accessor (ref: 4089...
3510 \t(FAMIX.AnnotationTypeAttribute (id: 6997)(na...
3511 \t(FAMIX.Invocation (id: 6998)(candidates (ref...
3512 \t(FAMIX.Access (id: 6999)(accessor (ref: 934)...
3513 \t(FAMIX.Inheritance (id: 7000)(subclass (ref:...
3514 \t(FAMIX.Invocation (id: 7001)(candidates (ref...
3515 \t(FAMIX.IndexedFileAnchor (id: 7002)(element ...

3460 rows × 1 columns


In [76]:
mse[(mse.raw.str.startswith('"')) & (mse.raw.str.endswith('"'))]


Out[76]:
raw

In [73]:
mse.raw.to_csv(
    r"C:\Temp\famix\buschmais_spring_petclinic_joa.csv",
    index=None,
    header=None)

In [72]:
mse[0].to_clipboard(index=None)


---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
C:\dev\apps\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
   2524             try:
-> 2525                 return self._engine.get_loc(key)
   2526             except KeyError:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 0

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
<ipython-input-72-b6f8871a78f4> in <module>()
----> 1 mse[0].to_clipboard(index=None)

C:\dev\apps\Anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key)
   2137             return self._getitem_multilevel(key)
   2138         else:
-> 2139             return self._getitem_column(key)
   2140 
   2141     def _getitem_column(self, key):

C:\dev\apps\Anaconda3\lib\site-packages\pandas\core\frame.py in _getitem_column(self, key)
   2144         # get column
   2145         if self.columns.is_unique:
-> 2146             return self._get_item_cache(key)
   2147 
   2148         # duplicate columns & possible reduce dimensionality

C:\dev\apps\Anaconda3\lib\site-packages\pandas\core\generic.py in _get_item_cache(self, item)
   1840         res = cache.get(item)
   1841         if res is None:
-> 1842             values = self._data.get(item)
   1843             res = self._box_item_values(item, values)
   1844             cache[item] = res

C:\dev\apps\Anaconda3\lib\site-packages\pandas\core\internals.py in get(self, item, fastpath)
   3841 
   3842             if not isna(item):
-> 3843                 loc = self.items.get_loc(item)
   3844             else:
   3845                 indexer = np.arange(len(self.items))[isna(self.items)]

C:\dev\apps\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
   2525                 return self._engine.get_loc(key)
   2526             except KeyError:
-> 2527                 return self._engine.get_loc(self._maybe_cast_indexer(key))
   2528 
   2529         indexer = self.get_indexer([key], method=method, tolerance=tolerance)

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 0

In [47]:
beginning = mse[mse.raw.str.startswith("\t(")].raw
beginning = beginning.str.extract("\t\(FAMIX\.(.*)", expand=False)
beginning = beginning.str.replace("(","{")
beginning = beginning.str.replace("}","}")
beginning = beginning.str.replace("id","famixId")
beginning = beginning


Out[47]:
1                             Invocation {famixId: 1)
5                             Invocation {famixId: 2)
9                                 Access {famixId: 3)
13                     IndexedFileAnchor {famixId: 4)
18                     IndexedFileAnchor {famixId: 5)
23                               Comment {famixId: 6)
30                     IndexedFileAnchor {famixId: 7)
35                            Invocation {famixId: 8)
39                     IndexedFileAnchor {famixId: 9)
44                               Access {famixId: 10)
48                           Invocation {famixId: 11)
52                    IndexedFileAnchor {famixId: 12)
57                               Method {famixId: 13)
64                    IndexedFileAnchor {famixId: 14)
69                        LocalVariable {famixId: 15)
74                    IndexedFileAnchor {famixId: 16)
79                   AnnotationInstance {famixId: 17)
84                           Invocation {famixId: 18)
89                               Access {famixId: 19)
93                        LocalVariable {famixId: 20)
98                    IndexedFileAnchor {famixId: 21)
103                  AnnotationInstance {famixId: 22)
108                              Method {famixId: 23)
116                   IndexedFileAnchor {famixId: 24)
121                   IndexedFileAnchor {famixId: 25)
126                               Class {famixId: 26)
131                       LocalVariable {famixId: 27)
136                           Namespace {famixId: 28)
140                          Invocation {famixId: 29)
145                              Method {famixId: 30)
                             ...                     
62818                         Method {famixId: 13238)
62825              IndexedFileAnchor {famixId: 13239)
62830                         Method {famixId: 13240)
62837                     Invocation {famixId: 13241)
62841              IndexedFileAnchor {famixId: 13242)
62846                     Invocation {famixId: 13243)
62851              IndexedFileAnchor {famixId: 13244)
62856                     Invocation {famixId: 13245)
62861                         Access {famixId: 13246)
62866              IndexedFileAnchor {famixId: 13247)
62871                     Invocation {famixId: 13248)
62876        AnnotationTypeAttribute {famixId: 13249)
62879              IndexedFileAnchor {famixId: 13250)
62884                     Invocation {famixId: 13251)
62889                         Access {famixId: 13252)
62893                         Method {famixId: 13253)
62901    AnnotationInstanceAttribute {famixId: 13254)
62905              IndexedFileAnchor {famixId: 13255)
62910                         Method {famixId: 13256)
62918                     Invocation {famixId: 13257)
62923              IndexedFileAnchor {famixId: 13258)
62928              IndexedFileAnchor {famixId: 13259)
62933    AnnotationInstanceAttribute {famixId: 13260)
62937                    Inheritance {famixId: 13261)
62940              IndexedFileAnchor {famixId: 13262)
62945                 AnnotationType {famixId: 13263)
62950              IndexedFileAnchor {famixId: 13264)
62955                     Invocation {famixId: 13265)
62959                         Access {famixId: 13266)
62963           ParameterizableClass {famixId: 13267)
Name: raw, Length: 13267, dtype: object

In [24]:
mse['end'] = mse.raw.str.extract("(.*)\)\)", expand=True).str.replace("\t")
mse.head()


Out[24]:
raw begin end
0 ( NaN NaN
1 \t(FAMIX.Invocation (id: 1) (FAMIX.Invocation (id: 1 NaN
2 \t\t(sender (ref: 6762)) NaN \t\t(sender (ref: 6762
3 \t\t(signature 'out.write(" ")') NaN NaN
4 \t\t(sourceAnchor (ref: 4709))) NaN \t\t(sourceAnchor (ref: 4709)