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, 2019 in Python by Esha
350 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, 2019 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
1,000 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, 2019 in Python by Will
1,069 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, 2019 in Python by Likhita
126 views
0 votes
1 answer
+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, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 530 views
0 votes
0 answers
+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, 2019 in Python by Nymeria
• 3,520 points
119 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, 2019 in Python by Arvind
• 2,980 points

edited Jun 26, 2019 by Kalgi 75 views