Home > Blockchain >  How do I convert one column of a csv file to a txt file in Python?
How do I convert one column of a csv file to a txt file in Python?

Time:02-21

I have a specific column in a csv file and I want to write each row of that column as a newline in the same txt file. I'm using Panda if that helps. I can't quite figure out how to iterate over the rows of one specific column.

CodePudding user response:

This should work:

dataframe[colname].to_csv('filepath.txt', sep="\n", index=False)

add header = False if you don't need the column name in that .txt file

  • Related