Create Pandas DataFrame from txt file with specific pattern

前端 未结 6 2437
北海茫月
北海茫月 2020-11-22 09:04

I need to create a Pandas DataFrame based on a text file based on the following structure:

Alabama[edit]
Auburn (Aubu         


        
6条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 09:18

    You will probably need to perform some additional manipulation on the file before getting it into a dataframe.

    A starting point would be to split the file into lines, search for the string [edit] in each line, put the string name as the key of a dictionary when it is there...

    I do not think that Pandas has any built in methods that would handle a file in this format.

提交回复
热议问题