Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-07-20
2
Medium Priority
?
10,256 Views
Last Modified: 2014-07-21
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
0
Comment
Question by:Ricky Ng
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
Lieven Embrechts earned 1600 total points
ID: 40208430
0
 
LVL 5

Assisted Solution

by:Pasha Kravtsov
Pasha Kravtsov earned 400 total points
ID: 40209289
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

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The really strange introduction Once upon a time there were individuals who intentionally put the grass seeds to the soil with anticipation of solving their nutrition problems. Or they maybe only played with seeds and noticed what happened... Som…
This article will show the steps for installing Python on Ubuntu Operating System. I have created a virtual machine with Ubuntu Operating system 8.10 and this installing process also works with upgraded version of Ubuntu OS. For installing Py…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question