I have two CSV files stored on S3. When I open one of them, File returns. When I open another, StringIO returns.
fn1 #=> "http://SOMEWHERE.s3.amazonaws.com/setup_data/d1/file1.csv" open(fn1) #=> #<File:/var/folders/sm/k7kyd0ns4k9bhfy7yqpjl2mh0000gn/T/open-uri20140814-26070-11cyjn1> fn2 #=> "http://SOMEWHERE.s3.amazonaws.com/setup_data/d2/d3/file2.csv" open(fn2) #=> #<StringIO:0x007f9718670ff0>
Why? Is there a way to open them using a consistent data type?
I need to pass the same String data type to CSV.read(open(file_url)) , which does not work if sometimes it receives File , and sometimes StringIO .
They were created using different ruby ββscripts (they contain very different data).
On my Mac, they both look like regular CSV text files, and they were expanded through the AWS console and have the same permissions and identical metadata (content-type: application / octet-stream).
source share