Practical Data Science using Python. To write pandas dataframe to a CSV file in Python, use the tocsv () method. At first, let us create a dictionary of lists . Now, create. Sep 02, 2020 Text File without headers Then while writing the code you can specify headers. Python3 import pandas as pd websites pd.readcsv ("GeeksforGeeks.txt" ,header None) websites.columns &39;Name&39;, &39;Type&39;, &39;Website&39; websites.tocsv (&39;GeeksforGeeks.csv&39;, index None) Output CSV file with headers. .