小编arj*_*ori的帖子

在不使用Google云端存储的情况下将BigQuery数据导出为CSV

我目前正在编写一个软件,用于导出大量BigQuery数据并将查询结果作为CSV文件存储在本地.我使用Python 3和谷​​歌提供的客户端.我做了配置和验证,但问题是,我无法在本地存储数据.每次执行时,我都会收到以下错误消息:

googleapiclient.errors.HttpError:https://www.googleapis.com/bigquery/v2/projects/round-office-769/jobs ?alt = json返回"无效的提取目标URI"响应/文件名 - *.csv' .必须是有效的Google存储路径.">

这是我的工作配置:

def export_table(service, cloud_storage_path,
             projectId, datasetId, tableId, sqlQuery,
             export_format="CSV",
             num_retries=5):

# Generate a unique job_id so retries
# don't accidentally duplicate export
job_data = {
    'jobReference': {
        'projectId': projectId,
        'jobId': str(uuid.uuid4())
    },
    'configuration': {
        'extract': {
            'sourceTable': {
                'projectId': projectId,
                'datasetId': datasetId,
                'tableId': tableId,
            },
            'destinationUris': ['response/file-name-*.csv'],
            'destinationFormat': export_format
        },
        'query': {
            'query': sqlQuery,
        }
    }
}
return service.jobs().insert(
    projectId=projectId,
    body=job_data).execute(num_retries=num_retries)
Run Code Online (Sandbox Code Playgroud)

我希望我可以使用本地路径而不是云存储来存储数据,但我错了.

所以我的问题是:

我可以在本地(或本地数据库)下载查询数据,还是必须使用Google云端存储?

python google-bigquery

13
推荐指数
3
解决办法
1万
查看次数

如何使用Node.js将JSON数组转换为CSV?

我想转换有值数组的json. response.json

{
"rows": [
[
  "New Visitor",
  "(not set)",
  "(not set)",      
  "0"
],
[
  "New Visitor",
  "(not set)",
  "(not set)",
  "mobile"      
],
[
  "New Visitor",
  "(not set)",
  "(not set)",
  "mobile"    
],
  [
    "New Visitor",
    "(not set)",
    "(not set)",
   "mobile",      
  ]
 ]
}
Run Code Online (Sandbox Code Playgroud)

现在我想将这些数据转换成. name.csv

 "New Visitor","(not set)","(not set)","0"
 "New Visitor","(not set)","(not set)","mobile"        
 "New Visitor","(not set)","(not set)","mobile"    
 "New Visitor","(not set)","(not set)","mobile"
Run Code Online (Sandbox Code Playgroud)

请使用Node.js给我建议.

csv json node.js express

11
推荐指数
2
解决办法
2万
查看次数

How to set HttpOnly flag In Node.js ,Express.js application?

Hi I have a project in node.js and I want to set the HttpOnly flag: true for header response.

I have written the following code in app.js but it make no effect in response header .

app.use(session({
 secret: "notagoodsecretnoreallydontusethisone",
 resave: false,
 saveUninitialized: true,
 cookie: {httpOnly: true, secure: true}
}));
Run Code Online (Sandbox Code Playgroud)

因此,对于设置任何建议的HttpOnly标志express.js深受欢迎。

javascript node.js express

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

express ×2

node.js ×2

csv ×1

google-bigquery ×1

javascript ×1

json ×1

python ×1