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

+1 vote
I have a csv file with 1000 records. I need to add these records to a list in python? is this possible? If yes how to do it?
Jun 25 in Python by Neel
• 3,010 points
59 views

1 answer to this question.

+1 vote

If you are using Python 3.x then the following these steps :-

  • 1. Import csv module.
  • 2. Open the file 
  • 3. Read the file.
  • 4. Convert it into list
  • 5.Print the list
import csv
with open('records.csv', 'r') as f:
  file = csv.reader(f)
  my_list = list(file)
print(my_list)
answered Jun 25 by Arvind
• 2,960 points

edited Jun 26 by Kalgi

Related Questions In Python

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
853 views
0 votes
1 answer

How to create LIST from CSV file in Python?

You can use the pandas library for this which ...READ MORE

answered Jul 15 in Python by Karan
144 views
0 votes
1 answer
0 votes
1 answer

How to Print a List in Python

ou are using Python 2.x syntax with ...READ MORE

answered Aug 31, 2018 in Python by charlie_brown
• 7,720 points
109 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 409 views
0 votes
1 answer

How to get a list of built in modules in Python?

simply open the python shell and type ...READ MORE

answered Aug 1 in Python by Arvind
• 2,960 points
97 views
+1 vote
1 answer

How to install a module in Python 3.6 ?

If you are using Ubuntu then the ...READ MORE

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