I am trying to download a csv file from an s3 bucket using the s3fs library. I have noticed that writing a new csv using pandas has altered data in some way. So I want to download the file directly in its raw state.
The documentation has a download function but I do not understand how to use it:
download(self, rpath, lpath[, recursive])
: Alias of FilesystemSpec.get.
Here's what I tried:
import pandas as pd
import datetime
import os
import s3fs
import numpy as np
#Creds for s3
fs = s3fs.S3FileSystem(key=mykey, secret=mysecretkey)
bucket = "s3://mys3bucket/mys3bucket"
files = fs.ls(bucket)[-3:]
#download files:
for file in files:
with fs.open(file) as f:
fs.download(f,"test.csv")
AttributeError: 'S3File' object has no attribute 'rstrip'