How do I import a .csv file using Python into Anaconda?

Hello Experts,

How do I import a .csv file using Python into Anaconda? I am using Spyder for the first time and am completely lost. I want to load data from a .csv file on a local directory.

Thanks
Ricky NgAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Lieven EmbrechtsConnect With a Mentor Senior IT ConsultantCommented:
0
 
Pasha KravtsovConnect With a Mentor Support EngineerCommented:
Here is a short example. What this does is open the csv for reading, loads it, and then prints it out row for row. If you need anymore help implementing what you're doing feel free to comment.
from csv import reader
with open('/path/to/csv/file.csv', 'rb') as csvFile:
  csvReader = reader(csvFile, delimiter=' ', quotechar='|')
  for row in csvReader:
    print ', '.join(row)

Open in new window

0
All Courses

From novice to tech pro — start learning today.