Extract data to S3 for objs that are not C3types

#1

Hi C3 Community,

I am currently working with a customer who wants a very specific extract of data and I was thinking about extracting through S3 (it would create almost 350 files). When I am doing it for one type it is working as a charm but when I am doing it for a custom object it is not.

I was wondering if we have the possibility to write data to S3 like S3File.writeObjs when the data is an array of objs that are not C3Types. (they need CSV lines containing data from different types)
I am looking to the same capabilities as c3CSV() but for S3 file storing.

I know that a solution could be to create a new type and store the data I want to export inside but I’d rather not choose this solution because I have a lot of data to export (mostly measurements).

Thanks !

0 Likes

#2

I would look into the writeString API - looks like does not need a “type” format ( looking for some example to provide)

 var s3Filename =  "file1.csv",
          file = S3.createFile(s3Filename),
          fileContents = ["parent.id,start,quantity.value,isNull"];

      for (var i = 0; i < 96; i++) {
        fileContents.push([
          randomid,
          start.plusHours(i).serialize(),
          Math.random(),
          0
        ].join(","));
      }

      file.writeString(fileContents.join("\n"));
1 Like

#3

Thank you Marco, it works !

0 Likes