I am downloading csv file from AWS S3 bucket so that I can use it in D3.
No problem downloading the csv file. In code below the console.log(data.Body.toString()) prints out the csv file contents in expected format
However, I am not sure how to pass the downloaded csv file content to D3 in code below.
The file contents are already in nice csv file format.
Question: how to replace merged.csv below with the mergedcsv object?
<script type="text/javascript">
var bucket = new AWS.S3();
bucket.getObject({
Bucket: 's3-google-analytics',
Key: 'merged.csv'
},
function awsDataFile(error, data) {
if (error) {
return console.log(error);
}
mergedcsv = data.Body.toString();
console.log(data.Body.toString());
}
);
// how to replace the "merged.csv" below with the mergedcsv object above?
d3.csv("merged.csv", function(data) {
var parseDate = d3.time.format("%Y%m%d").parse;
var counter = 0;
data.forEach(function(d) {
etc
});
});
</script>
updated to add sample of mergedcsv content eg output of console.log(mergedcsv); or console.log(data.Body.toString()); :
yyyymm,date,hostname,source,PPCC,in30days,sessionDuration,users,sessions,newUsers,twitterSessions,bounceRate,sessionsPerUser
201203,20120330,journal,google,PPCC,>30days,26.25,4,4,4,0,75.0,1.0
201203,20120331,journal,(direct),PPCC,>30days,0.0,3,3,3,0,100.0,1.0
201203,20120331,journal,bing,PPCC,>30days,0.0,1,1,1,0,100.0,1.0
mergedcsv?