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.
Asked
Active
Viewed 1,607 times
1
-
1Non-Python answer: `cut -d';' -f
`. ;-) – DevSolar Feb 18 '22 at 17:03 -
Do you want to append a column data to same csv file from which you are reading data? Or to a new txt file? – Manjunath K Mayya Feb 18 '22 at 17:16
-
Will you please edit your question and include a small sample input, and how "each row of that column as a newline" looks "in the same txt file"? thanks! :) – Zach Young Feb 19 '22 at 00:18
1 Answers
1
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

Max Skoryk
- 404
- 2
- 10