Solved

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

Posted on 2014-07-20
2
5,127 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
Comment Utility
0
 
LVL 5

Assisted Solution

by:Pasha Kravtsov
Pasha Kravtsov earned 100 total points
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Variable is a place holder or reserved memory locations to store any value. Which means whenever we create a variable, indirectly we are reserving some space in the memory. The interpreter assigns or allocates some space in the memory based on the d…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now