Skip to main content

No project description provided

Project description

Here’s a polished version of your README with improved grammar, clearer instructions, and some additional helpful details:


Usage

1. Install Sheetrika

  1. Create a virtual environment (recommended to isolate dependencies):
    python3 -m venv .venv
    
  2. Install Sheetrika inside the virtual environment:
    .venv/bin/pip install sheetrika
    

2. Enable Google Sheets API

  1. Go to the Google Cloud Console API Library.
  2. Search for Google Sheets API.
  3. Click Enable to activate the API for your project.

3. Create a Service Account

  1. Navigate to the Google Cloud Console Credentials page.
  2. Click Create Service Account and follow the prompts.
  3. In the Service Account settings, go to the Keys tab and click Add KeyJSON. Save the file as creds.json.
  4. Encode the credentials for secure use:
    .venv/bin/sheetrika encode creds.json
    
  5. Copy the output and save it to a new .env file. Example:
    export GOOGLE_API_TOKEN="your_encoded_token_here"
    

4. Configure Demo Parameters in config.yml

  1. Google Spreadsheet Setup:
    • Create a new spreadsheet or open an existing one.
    • Extract the spreadsheet_id from the URL:
      https://docs.google.com/spreadsheets/d/{spreadsheet_id}/edit
      
    • Add the client_email from creds.json to the spreadsheet’s sharing permissions (as an editor).
  2. Yandex Metrica Parameters:

Example config.yml:

tasks:
  - name: live_demo__y_metrica
    query:
      url: https://api-metrika.yandex.ru/stat/v1/data/bytime.csv
      params:
        date1: 3daysAgo
        date2: today
        id: <your_metrica_counter_id>
        metrics: ym:s:visits,ym:s:users
        dimensions: ym:s:TrafficSource
        group: day
        filters: ym:s:isRobot=='No'
      schema:
        - Период
        - Переходы из поисковых систем
        - Переходы по ссылкам на сайтах
        - Прямые заходы
        - Внутренние переходы
        - Переходы из социальных сетей
        - Переходы из рекомендательных систем
    sheet:
      spreadsheet_id: <your_spreadsheet_id>
      name: main
      range: A2
      wtype: merge

5. Get a Yandex API Token

  1. Follow the Yandex Metrica Authorization Guide to obtain a token.
  2. Save the token to your .env file:
    export YANDEX_API_TOKEN="your_yandex_token_here"
    

6. Run the Example

Load the environment variables and execute the script:

import os
from sheetrika.loader import SheetrikaLoader

def main():
    loader = SheetrikaLoader(
        ym_token=os.getenv('YANDEX_API_TOKEN'),
        goo_token=os.getenv('GOOGLE_API_TOKEN'),
        config_path='config.yaml',
    )
    loader.run()

if __name__ == '__main__':
    main()

Writing Types (wtype Options)

  1. snapshot: Clears all data in the specified range and writes new data.
  2. append: Finds the first empty row and appends data below it.
  3. merge: Matches values in the first column and updates non-intersecting rows.

Additional Notes:

  • Virtual Environment: Always activate your virtual environment before running commands:
    source .venv/bin/activate  # Linux/Mac
    .venv\Scripts\activate     # Windows
    
  • Security: Keep creds.json and .env files out of version control (add them to .gitignore).
  • Debugging: If permissions fail, ensure the client_email has edit access to the spreadsheet.

Let me know if you'd like further refinements!

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

sheetrika-0.1.3.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

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

sheetrika-0.1.3-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file sheetrika-0.1.3.tar.gz.

File metadata

  • Download URL: sheetrika-0.1.3.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for sheetrika-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2393ab44bb588bb5d93dc94b65a6ae02ea7162b184dd07c2cf7bf570adef8bd0
MD5 7ab0d3dac5c5a528dc43f7b3f1f37df9
BLAKE2b-256 4f0cc70df039a8657ecf8555840dc1cf1f0ea74d32b5592123917b4033e78d22

See more details on using hashes here.

File details

Details for the file sheetrika-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: sheetrika-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for sheetrika-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0bb9815d8c3f269182f5b724376ebd15f384c2f50e04dfac1fe090c21c587b9a
MD5 a0c08a7fc1fc04d4725b79da4de0a21c
BLAKE2b-256 7c8a8938f2d2a4cca4e8d18aa90b77a39bf4e822e30fa4e0479c522e062dd1b3

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