Amazon web services 优化ETL过程和平台

Amazon web services 优化ETL过程和平台,amazon-web-services,google-bigquery,etl,Amazon Web Services,Google Bigquery,Etl,我面临以下问题,我是云计算和数据库的新手。我想为应用程序设置一个简单的仪表板。基本上我想复制这个显示空气污染数据的网站 在我的认知中,我需要做以下几点: 从API下载数据:我特别记住了这个链接——过去一小时每个传感器所有测量值的平均值。技术:Python机器人 设置一个机器人来稍微转换数据,以便根据我们的需要进行调整。技术:Python 将数据上传到数据库。技术:谷歌大查询或AWS 将数据库连接到可视化工具,这样每个人都可以在我们的网页上看到它。技术:可能是Python中的Dash 我的问题如下

我面临以下问题,我是云计算和数据库的新手。我想为应用程序设置一个简单的仪表板。基本上我想复制这个显示空气污染数据的网站

在我的认知中,我需要做以下几点:

从API下载数据:我特别记住了这个链接——过去一小时每个传感器所有测量值的平均值。技术:Python机器人 设置一个机器人来稍微转换数据,以便根据我们的需要进行调整。技术:Python 将数据上传到数据库。技术:谷歌大查询或AWS 将数据库连接到可视化工具,这样每个人都可以在我们的网页上看到它。技术:可能是Python中的Dash 我的问题如下。 1.你同意我的思维过程吗?还是你会改变一些元素使之更有效率? 2.您认为运行python脚本来转换数据怎么样?有没有更简单的办法? 3.您建议使用哪种技术来设置数据库

谢谢你的评论! 顺致敬意,
Bartek

如果您想对数据进行一些分析,我建议将数据上传到BigQuery,完成后,您可以在这里创建新的查询并获得要分析的结果。我正在检查dataset data.1h.json,我将使用如下模式在BigQuery中创建一个表:

CREATE TABLE dataset.pollution
(
  id NUMERIC,
  sampling_rate STRING,
  timestamp TIMESTAMP,
  location STRUCT<
  id NUMERIC,
  latitude FLOAT64,
  longitude FLOAT64,
  altitude FLOAT64,
  country STRING,
  exact_location INT64,
  indoor INT64
  >,
  sensor STRUCT<
    id NUMERIC,
    pin STRING,
    sensor_type STRUCT<
      id INT64,
      name STRING,
      manufacturer STRING
    >
  >,
  sensordatavalues ARRAY<STRUCT<
    id NUMERIC,
    value FLOAT64,
    value_type STRING
  >>
)
正如您在上面看到的,为了避免达到请求大小的配额,我必须创建一个分区。在这里您可以看到要避免的配额数量[3]

此外,位置字段中的某些数据似乎有空值,因此有必要对其进行控制以避免错误

由于您已经将数据存储在BigQuery中,为了创建一个新的仪表板,我将使用DataStudio工具[4]可视化BigQuery数据,并在要显示的列上创建查询

[1]

[2]

[3]


[4]

谢谢冈萨洛的建议!关于DataStudio的建议特别有用!嗨,巴特克,如果你觉得冈萨罗的回答很有帮助,我鼓励你接受它:
from google.cloud import storage
import json
from google.cloud import bigquery

client = bigquery.Client()

table_id = "project.dataset.pollution"
# Instantiate a Google Cloud Storage client and specify required bucket and 
file
storage_client = storage.Client()
bucket = storage_client.get_bucket('bucket')
blob = bucket.blob('folder/data.1h.json')
table = client.get_table(table_id)
# Download the contents of the blob as a string and then parse it using 
json.loads() method
data = json.loads(blob.download_as_string(client=None))

# Partition the request in order to avoid reach quotas
partition = len(data)/4

cont = 0
data_aux = []
for part in data:
    if cont >= partition:
        errors = client.insert_rows(table, data_aux)  # Make an API request.
        if errors == []:
            print("New rows have been added.")
        else:
            print(errors)
        cont = 0
        data_aux = []
    # Avoid empty values (clean data)
    if part['location']['altitude'] is "":
        part['location']['altitude'] = 0
    if part['location']['latitude'] is "":
        part['location']['latitude'] = 0
    if part['location']['longitude'] is "":
        part['location']['longitude'] = 0
    data_aux.append(part)
    cont += 1