0

i just started using python and i've been trying to read a file the code doesn't return any errors but it shows this message on the debugging screen

  <_csv.reader object at 0x035022B0>

i searched but i couldn't find any answers i even tried other sample codes to see if the problem is in my writing but it returned the same message

*Note = the file is in the same directory of the project

this is my code

import csv

with open('nora.csv', mode='r') as CSVFile:

   read = csv.reader(CSVFile, delimiter =",")
   print(read)

   CSVFile.close()

thank you for your help in advance

Al Nnor
  • 23
  • 3

2 Answers2

0

Try using pandas to read csv files - it will place the csv information in a dataframe for you.

import pandas as pd

#Place the csv data into a DataFrame
file = pd.read_csv("/path/to/file.csv")

print file
Tom Patel
  • 422
  • 1
  • 4
  • 11
0

i still don't know what that message meant but i added a for loop to read instead of just adding print and it worked

import csv

with open('players.csv', mode='r') as CSVFile:

  read = csv.reader(CSVFile, delimiter =",")

  for row in read :
      print(row)

  CSVFile.close()

thank you guys for helping <3 <3

Al Nnor
  • 23
  • 3