Importing “.csv” Files Using Jupyter Notebook

This will be my second blog post describing how to import CSV (Comma separated values) files into your desired platform to work with. My first post discusses how to import data into Google Colaboratory, a link to it can be found here. In this post I will be explaining methods for working specifically with Jupyter Notebook.

Method 1…

Both of the methods that I will discuss require pandas to work successfully, you can use the cell found below to import it. You will also want to have the file or files that you’re trying to work with to be in an easy to locate file path.

import pandas as pd

After you have imported pandas you will want to acquire the file path of your CSV file. Instructions on how to do this can be found here for Windows, and then for Macs. Once you have the file path copied you will want to use the code cell below to read in your file, it is important you include the “r” at the start of your file path.

df = pd.read_csv(r"C:\Users\leerowe\Desktop\data_to_upload.csv")

Method 2…

This method is quite literally the same as the first, the only differences are that you don’t need to include the “r”. Once again to start, you will need pandas imported. After that you will still need to acquire your file path, after you have it copied and ready to paste, you will want to make sure to use double backslashes “ \\ ” as seen in the cell below.

import pandas as pddf = pd.read_csv("C:\\Users\\leerowe\\Desktop\\data_to_upload.csv")
Photo by Stone Wang on Unsplash

Hopefully one of these methods give you a helpful insight into your file importing process!

--

--

--

Data Operations Manager at BOTAŞ | Create Value | if data: data.science()

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Fresh new Spinnaker content @ CDCon

Notification Center Simplified.(Swift)

How to make you’re daily activity as SRE/DevOps better using Slack BOT!

Enable/Disable Drop Shadow in Mac Screenshots

How Hootsuite does Microservices

Multithreading and Multiprocessing in Python

3 Steps to Configure DNS to Improve Deliverability and Security of an Email

Quality Attributes (*-ilities) In Application Development

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
@lee-rowe

@lee-rowe

Data Operations Manager at BOTAŞ | Create Value | if data: data.science()

More from Medium

How to get around of the “UnicodeEncodeError: ‘utf-8’ codec can’t encode character …: surrogates…

Make Pivot Tables in Python with Mito

Scheduling Python scripts through Windows Task Scheduler

Installing Anaconda for Python Development