How to create LIST from CSV file in Python?

0 votes
I wanted to know how to create LIST element from CSV. Can you please provide the code for this?
Jul 15 in Python by Esha
37 views

1 answer to this question.

0 votes

You can use the pandas library for this which has an inbuilt method to convert values to list. Refer to the code below:

import pandas as pd

df = pd.read_csv("welcome.csv")

df.values.tolist()

print(df)
answered Jul 15 by Karan

Related Questions In Python

0 votes
1 answer
0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

answered Apr 17, 2018 in Python by anonymous
726 views
0 votes
1 answer

How to create blank csv file in pandas?

Try this code: open("User data.csv", 'w') Where User data.csv ...READ MORE

answered Apr 5 in Python by Will
648 views
0 votes
1 answer

How to create Pandas dataframe from Python list?

You can do it like this: import ...READ MORE

answered Apr 5 in Python by Likhita
74 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 279 views
+4 votes
6 answers
0 votes
1 answer

How to create and read from a temporary file in Python?

Hi, there is a very simple solution ...READ MORE

answered Jan 29 in Python by Nymeria
• 3,520 points
80 views
+1 vote
1 answer

How to convert records from csv to a list in Python?

If you are using Python 3.x then ...READ MORE

answered Jun 25 in Python by Arvind
• 2,960 points

edited Jun 26 by Kalgi 48 views