I am trying to read a CSV from amazon S3 bucket (this could be any CSV so I do not have the header/datatype info ahead of read.
I am able to get the header info using :
const params = {
Bucket: 'mybucket',
Key: file,
ExpressionType: 'SQL',
Expression: 'SELECT * FROM S3Object s LIMIT 1',
InputSerialization: {
CSV: {
FileHeaderInfo: 'NONE',
RecordDelimiter: '\n',
FieldDelimiter: ','
}
},
OutputSerialization: {
CSV: {}
}
};
This gives me the header info.
Is there a way to get the nearest datatype (or is it always as a string). Is there any other way to get the datatype of csv in javascript. (If I know the columns I can cast but this is dynamic)
S3 Select docs says it is possible to do aggregates but on trying the same it always errors with "The column index at line 1, column 12 is invalid. Please check the service documentation and try again."
select MAX(cast(totalamount as float)) from s3object s
Error
The column index at line 1, column 12 is invalid. Please check the service documentation and try again.
Thanks