Skip to main content

upload data from oss to maxcompute and import to matrix lib table

Project description

upload oss data to maxcompute

initialize maxcompute account

  • Install Aliyun CLI: Install guide
  • run the aliyun configure command to setup account
$ aliyun configure
Configuring profile 'default' ...
Aliyun Access Key ID [None]: <Your AccessKey ID>
Aliyun Access Key Secret [None]: <Your AccessKey Secret>
Default Region Id [None]: cn-zhangjiakou
Default output format [json]: json
Default Language [zh]: zh

define data source

define data source:

{
    "$schema": "../data2cloud/schemas/json/data-config-schema.json",
    "vender": "csmar",
    "meta_table": "metadata_csmar",
    "data_type": {
        "type": "oss",
        "location": "oss://oss-cn-zhangjiakou-internal.aliyuncs.com/dteam2022-data/source_data/csmar"
    },
    "data_versions": [
        {
            "source": "cg_ybasic",
            "versions": [
                "20240506"
            ]
        }
    ],
    "data": [
       {
            "source": "cg_ybasic",
            "target_table": "ods_csmar_cg_ybasic",
            "source_name": "治理综合信息文件",
            "meta": [
                {
                    "col_order": 1,
                    "col_name": "Stkcd",
                    "col_type": "Nvarchar",
                    "col_name_desc": "证券代码",
                },
                {
                    "col_order": 2,
                    "col_name": "Reptdt",
                    "col_type": "Datetime",
                    "col_name_desc": "统计截止日期",

                },
                {
                    "col_order": 4,
                    "col_name": "Y0301b",
                    "col_type": "decimal",
                    "col_name_desc": "股本结构是否变化",
                    "col_desc": "1=未变化,2=有变化。"
                },
                {
                    "col_order": 16,
                    "col_name": "ManagerHoldsharesRatio",
                    "col_type": "decimal",
                    "col_name_desc": "总经理持股比例",
                    "col_unit": "%"
                },
                ...
            ]
        }, 
    ],
    "matrix": [{
            "source": "cg_ybasic",
            "target_code_prefix": "cg_ybasic",
            "source_col_prefix": "Y",
            "eff_date_col": "Reptdt",
            "firm_col": "stkcd"
        }
    ]
}

upload data and import matrix

from pathlib import Path
from data2cloud.data_uploader import DataUploader, MatrixImporter, DataConfigParser

config_file = f"{Path(__file__).resolve().parent}/datasource/csmar.json"
uploader = DataUploader(config_file)
uploader.upload("cg_ybasic") # uploader.upload_all()
# import matrix
m_importer = MatrixImporter(config_file)
m_importer.import_matrix("cg_ybasic")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

data2cloud-0.0.2a0.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

data2cloud-0.0.2a0-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file data2cloud-0.0.2a0.tar.gz.

File metadata

  • Download URL: data2cloud-0.0.2a0.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for data2cloud-0.0.2a0.tar.gz
Algorithm Hash digest
SHA256 5f502e930479ea9a53f5cb29a4d039a0f1e8a3fcc58874a0246d2e04bbaf723b
MD5 251521ae01828935c8956c775b51e6d3
BLAKE2b-256 50e4e02131a6183303e7525b2f18d30720f267d7ca0adcd137b5a106ac61ef3d

See more details on using hashes here.

File details

Details for the file data2cloud-0.0.2a0-py3-none-any.whl.

File metadata

  • Download URL: data2cloud-0.0.2a0-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for data2cloud-0.0.2a0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b56b957d30ba44ac670bbbf90d2b3ada04be9df35690825f3fd3060abae1f71
MD5 d9b11d4421b23f593fcf2e9607c596b7
BLAKE2b-256 93adafff9f3fa3c2dd9e5dfb6f756f6040d5a79708db883223aeb5607e09c091

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page