Solved

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

Posted on 2014-07-20
2
7,041 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 400 total points
ID: 40208430
0
 
LVL 5

Assisted Solution

by:Pasha Kravtsov
Pasha Kravtsov earned 100 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Update 40,000 records in smaller chunk query - MDB to MSSQL 6 123
Macports Import beautifulsoup4 Problem 6 77
Python mysql Insert data error 3 95
IDE for Python 5 26
Less strange, but still introduction This introduction was added (1st August, 2011) to reflect some reactions.  Firstly, the term basics in the title of the article...  As any other word, it is a symbol with meaning attached to the word by some a…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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 while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

830 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