export spreadsheet as text/csv using drive v3 gives 500 internal error

  • Last Update :
  • Techknowledgy :

With file as the file ID, http as the http object that you've authorized against you can download a file with:

from apiclient.http
import HttpRequest
def postproc( * args):
   return args[1]
data = HttpRequest(http = http,
   postproc = postproc,
   uri = 'https://docs.google.com/feeds/download/spreadsheets/Export?key=%s&exportFormat=csv' % file,
   headers = {}).execute()

data here is a bytes object that contains your CSV. You can open it something like:

import io
lines = io.TextIOWrapper(io.BytesIO(data), encoding = 'utf-8', errors = 'replace')
for line in lines:
   #Do whatever

Here is an snippet of an implementation of Exponential Backoff from the first link:

ExponentialBackOff backoff = ExponentialBackOff.builder()
   .setInitialIntervalMillis(500)
   .setMaxElapsedTimeMillis(900000)
   .setMaxIntervalMillis(6000)
   .setMultiplier(1.5)
   .setRandomizationFactor(0.5)
   .build();
request.setUnsuccessfulResponseHandler(new HttpBackOffUnsuccessfulResponseHandler(backoff));

Suggestion : 2

Last updated: 2020-12-14

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::<your_bucket_name>",
                "arn:aws:s3:::<your_bucket_name>/*"
            ]
        }
    ]
}</your_bucket_name></your_bucket_name>
{
   "Version": "2012-10-17",
   "Statement": [{
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
         "Service": "rds.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
   }]
}
CREATE USER 'testsaveload'
@ '%'
IDENTIFIED BY 'somepassword’;
show grants
for 'testsaveload'
@ '%’;
GRANT SELECT, CREATE, INSERT, DROP ON * .*TO 'testsaveload'
@ '%’;
GRANT SELECT INTO S3 ON * .*TO 'testsaveload'
@ '%’;
GRANT LOAD FROM S3 ON * .*TO 'testsaveload'
@ '%’;
SELECT * from test1.test2034 INTO OUTFILE S3 's3://tests3saveloadaurora/testfile1prefix.part_00000';
LOAD DATA FROM S3 PREFIX 's3-us-east-1://tests3saveloadaurora/testfile1prefix.part_00000'
INTO TABLE test3001;
LOAD DATA FROM S3 's3-us-east-1://tests3saveloadaurora/prefix3.part_00000'
INTO TABLE test3000;
SELECT * from test1.test2034 INTO OUTFILE S3 '"s3://tests3saveloadaurora/testfile1prefix.part_00000';
Error Code: 1871. S3 API returned error: Missing Credentials: Cannot instantiate S3 Client

Suggestion : 3

Power Apps Export To Excel As A CSV File,If you have any questions or feedback about Power Apps Export To Excel As A CSV File please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.,In this article I will show you how to use Power Apps to export a file to Excel. ,Thank you Matthew, really good job, im need to implement this in my app, but in the line: “Set( varCSVFile, PowerAppsToExcel.Run(varCars).linkoutput );“, what is the value of this varCars and when this variable was set?

In this article I will show you how to use Power Apps to export a file to Excel.

Table of Contents:
   Introduction: The Car Sales Inventory App
Setup The SharePoint List
Insert A Table To Display Information In The App
Preparing A JSON Sample For The Export To Excel Flow
Creating The Export To Excel Flow
Connect The 'Export To Excel'
Flow In Power Apps
Download The CSV File And Open In Excel



Put this code in the OnSelect property of the button. The JSON function converts table data, whether from a datasource or from a collection, into text formatted as a JSON.

Set(
   varJSONCars,
   JSON(
      ShowColumns(
         FirstN('Car Sales Inventory', 3),
         "year",
         "make",
         "model",
         "color",
         "location",
         "cost"
      ),
      JSONFormat.IndentFour
   )
)



Then insert a label beside the button and put this code in the Text property.

varJSONCars
  1. Click the generate from sample button and copy + paste the the JSON we created in Power Apps earlier.
  2. A new document library called Export Data must added in SharePoint before selecting it in the create file step.
  3. The Flow will not create a new file if a CSV with the same name already exists. We can make sure this doesn’t happen by adding a timestamp to the end. Here’s the flow expression you should use.

formatDateTime(utcNow(), 'yyyyMMddhhmmss')



4. We want to encode the CSV file in UTF-8 format so it can handle special characters (accented letters, currency symbols, etc). For example, I had a problem where the Euro symbol (€) was not appearing correctly in my CSV file. To solve the issue, use this code. The 3 character prefix in-front of the body(‘Create_CSV_table) identifies the format to Power Automate as UTF-8.

concat(uriComponentToString('%EF%BB%BF'), body('Create_CSV_table'))