Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-07-20
2
Medium Priority
?
11,748 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
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

"The time has come," the Walrus said, "To talk of many things: Of sets--and lists--and dictionaries-- Of variable kinks-- And why you see it changing not-- And why so strange are strings." This part describes how variables and references (see …
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
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…
Suggested Courses
Course of the Month7 days, 7 hours left to enroll

824 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