-1

An example of a Line in my text file: Hellothisismyquestion56464

I want to my Data frame to look like this:

C1 C2 C3 C4 C5 C6
Hello this is my question 56464
Safi
  • 13
  • 4

1 Answers1

1

There are a variety of methods available to read a text file using pandas as mentioned here.

However, you need to specify a delimiter or a separator to achieve what you are trying to do. Following is an example code snippet of the same:

import pandas as pd
  
# read text file into pandas DataFrame and create header with names
df = pd.read_csv("gfg.txt", sep=" ", header=None, 
                 names=["Team1", "Team2"])
  
# display DataFrame
print(df)