简体   繁体   English

如何在 AWS EC2 上运行 Python 代码并将 csv 文件从服务器写入我的本地计算机?

[英]How to run a Python code on AWS EC2 and write a csv file from the server to my local machine?

I have a python program that ultimately writes a csv file using pandas:我有一个 python 程序,它最终使用 pandas 编写 csv 文件:

df.to_csv(r'path\file.csv)

I was able to upload the files to the server via FileZilla and was also able to run the program on the EC2 server normally.我能够通过 FileZilla 将文件上传到服务器,并且还能够在 EC2 服务器上正常运行该程序。 However, I would now like to export a csv file to my local machine, but I don't know how to.但是,我现在想将 csv 文件导出到我的本地计算机,但我不知道该怎么做。

Do I have to write the csv file directly to a cloud drive (eg google drive via Pydrive)?我是否必须将 csv 文件直接写入云驱动器(例如通过 Pydrive 的谷歌驱动器)? What would be the easiest way?最简单的方法是什么?

You probably do not want to expose your computer to the dangers of the Internet.您可能不想将您的计算机暴露在 Internet 的危险中。 Therefore, it is better for your computer to 'pull' the data down, rather than allowing something on the Internet to 'push' something to it.因此,最好让您的计算机将数据“拉”下来,而不是让 Internet 上的某些东西“推送”某些东西给它。

You could send the data to Amazon S3 or, if you are using a cloud-based storage service like Google Drive or Dropbox, use their SDK to upload the file to their storage.您可以将数据发送到 Amazon S3,或者,如果您使用的是 Google Drive 或 Dropbox 等基于云的存储服务,请使用他们的 SDK 将文件上传到他们的存储。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM