我正在Google Colab上进行一些数据预处理,只是想知道它如何处理数据集。例如,在您使用 let documentsUrl = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
// your destination file url
let destination = documentsUrl.appendingPathComponent(pathURL.lastPathComponent)
print(destination)
// check if it exists before downloading it
if FileManager().fileExists(atPath: destination.path) {
print("The file already exists at path")
} else {
// if the file doesn't exist
// just download the data from your url
URLSession.shared.downloadTask(with: pathURL, completionHandler: { (location, response, error) in
// after downloading your data you need to save it to your destination url
guard
let httpURLResponse = response as? HTTPURLResponse, httpURLResponse.statusCode == 200,
let location = location, error == nil
else {
self.showAlert(title: NSLocalizedString("Error", comment: "") , message: "")
return }
do {
try FileManager.default.moveItem(at: location, to: destination)
print("file saved")
} catch {
print(error)
}
}).resume()
}
导出更改后的数据集之前,R不会更改原始数据集。在colab中它是否也类似地工作?谢谢!
答案 0 :(得分:0)
在您明确保存更改的数据之前,例如使用df.to_csv
到您读取的相同文件,不会保存更改的数据集。
您必须记住,由于不活动(长达一个小时左右),colab会话可能会过期,所有进度都将丢失。
更新
!gdown https://drive.google.com/uc?id=FILE_ID
!git clone https://USERNAME:PASSWORD@github.com/username/project.git
wget
从Internet下载文件 !wget file_url