How to Upload Files to Remote Through Terminal

In this commodity, I'll answer a question that frequently comes up in my online courses, which is:

How do you upload a dataset (e.g. csv, txt or tsv raw data files) to a remote server?

It'due south a simple question and the answer is also very simple. Merely I get this from time to time, and so I assume that this is a common problem for people who merely got started learning information science. And hither'south the answer!

This article is bachelor in video format, too!

Local computer to remote server

The issue is simple.

You have your local reckoner, where you take a dataset — have this instance.csv or example2.csv file — and you want to upload this to your remote data server.

data files on local computer

I'll show you two solutions for this problem:

  1. in the get-go i, I'll use the command line (which I phone call the painful solution)
  2. in the second one, I'll use Jupyter, which is a web application that I mainly employ to epitome my Python code — but it'll exist very handy for this file-upload-issue, too.

At present, if you don't know what a remote data server is or you don't know what Jupyter is, check out my remote server setup tutorial beginning. In that commodity, I show you how yous can install Python and SQL step-by-step to acquire and practice data science in a existent-life-like environment.

But if y'all have these already, then just follow me.

Upload a dataset using the command line

Let'southward run into the painful solution first. In this article, I'll show you a solution that works on Mac and Linux only. But you can do similar things on Windows using PuTTY.

Either way, you don't have to worry well-nigh it because I show this to y'all only to demonstrate how painful it is — so you tin can improve appreciate the second solution that will work on all operating systems anyway. 😉

As a beginning step, open a Terminal window.

Right now, you lot are on your local computer. Go to the folder where yous store your information file locally. For me, it's

cd Desktop/instance/

And hither, I have instance.csv and example2.csv.

datasets computer command line

The side by side step is typing the actual control, which looks like this:

scp /Users/tomimester/Desktop/example/example.csv tomi@134.122.73.132:~/upload_demo/

Permit's break this down:

  • scp stands for secure copy protocol and it's the re-create command itself
  • then yous type your file proper noun (example.csv) — preferably with the full path included (/Users/tomimester/Desktop/example/case.csv). Note: if you are already in the folder where your files are located, it's fine to add together just the file name without the total path.
  • The next step is to specify where nosotros want to copy it to. You accept to add the details of your remote server, more than specifically the user name and the IP accost (for me it was tomi@134.122.73.132) then a colon and a tilde character (:~). These will specify that your file goes directly into your user's folder on your remote server. And so y'all take to specify the verbal binder you want to copy your file into (given that this folder exists on the server). For me, it'll be the upload_demo binder that I created earlier.
scp command line data files

So all in all, you need:

  • the copy control
  • the file you want to copy
  • and the destination on your remote server

Hit enter, type your password — and boom: the example.csv file is uploaded!

copy data file to server

Double-check your data file!

If you ssh to your server and go to the right folder, you'll come across that the file is there equally it should be.

data server file

Well, this was simply a small demo file — only you can upload bigger files, of course, using the scp control.

Anyways: from this point on, yous can utilise your dataset for your projects that are done on your remote data server. Nice stuff!


Okay, so this is how yous can upload a data file to your information server via the command line. (At least on Mac and Linux, only again: this can be done using PuTTY on windows.)

As I said, I find this process a flake painful, at least compared to the 2d solution, which is a point-and-click solution and also works on all operating systems.

Upload a dataset using Jupyter

For this second solution, you'll need Jupyter installed to your remote server already.

I assume that yous accept this — as well-nigh people who larn data scientific discipline and Python prefer to practise that using Jupyter Notebooks. But if you don't, cheque out the server setup tutorial I mentioned before.

Anyways, if you have Jupyter on your remote server, then, as a first pace, open Last (or PuTTY) and log in to your server.

ssh to a server dataset

And in one case y'all are logged in, you lot tin can offset Juptyer using the:

jupyter notebook --browser any

command.

jupyter dataset

Once information technology'due south running, get to a browser window (e.g. open a Google Chrome) and type [your server'south IP]:8888. (Just as we do all the time when running a Jupyter notebook.)

For me it's going to exist:

134.122.73.132:8888

Note: You'll also copy-paste your token from Terminal — or type your password if you have 1 already ready upward.

The practiced thing is that in Jupyter you can pretty much upload your file in the point-and-click way — because in the top right corner, there is an UPLOAD button. How user-friendly is that?

upload a file to a data server with jupyter

So just click to your folder called upload_demo.

Hither, you lot'll find the file that you've uploaded via the command line already.

upload a dataset to data server jupyter

And upload the example2.csv file past clicking the Upload button (in the meridian right corner), then select example2.csv in the window that pops up…

And then a new row shows upwardly in your file list — merely click Upload again to finalize the uploading procedure.

upload data file server jupyter

And there is your example2.csv dataset uploaded to your data server!

data file dataset server

Very very simple, but as I promised!

Determination

Okay, that'due south it, this is the simplest way to upload your datasets to a remote server… well, at least, if yous are a information scientist using Jupyter.

If not, you tin can notwithstanding take reward of the commencement method and apply scp — only again to be honest, I don't actually use that method whatsoever more, considering the Jupyter one is much, much more user-friendly.

  • If you want to learn more about how to go a information scientist, take my 50-infinitesimal video course: How to Become a Data Scientist. (It'due south gratuitous!)
  • Also cheque out my 6-week online course: The Inferior Information Scientist's First Month video course.

Cheers,
Tomi Mester

jonesmakered.blogspot.com

Source: https://data36.com/upload-dataset-to-a-server-command-line-jupyter/

0 Response to "How to Upload Files to Remote Through Terminal"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel