In this article, we are going to see how to convert CSV columns to text in Python, and we will also see how to convert all CSV column to text.
- Read .CSV file using pandas dataframe.
- Convert particular column to list using list() constructor
- Then sequentially convert each element of the list to a string and join them using a specific character or space.
For our program we are going to use the following CSV file:
Apple Banana JackFruit Orange Pineapple Guava Grapes Mango 100 70 30 120 90 50 80 200
How to convert all csv column to text ?
For this, we don’t need to import any library.
FRUIT_NAME PRICE Apple 100 Banana 70 JackFruit 30 Orange 120 Pineapple 90 Guava 50 Grapes 80 Mango 200
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.