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.5.tar.gz (8.4 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.5-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sheetrika-0.1.5.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.7 Darwin/24.6.0

File hashes

Hashes for sheetrika-0.1.5.tar.gz
Algorithm Hash digest
SHA256 1596fef762c3bcd77393e4f6f2335bee2c145898a597ee8c06f2716195503894
MD5 1688393402fe4d54129ba9149ecf30e3
BLAKE2b-256 2c52fd5c0db83a82acdf97670976712c8f555f0100b22ffef3063734b24147c1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sheetrika-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.7 Darwin/24.6.0

File hashes

Hashes for sheetrika-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 692a98008b7ef358ca005df12a4235eb47c24d26022930c8af3e41acbc00df84
MD5 13cc780fe58253501536ea62e8bfef91
BLAKE2b-256 6d707f937c9046dce01809f27a70f646562a2861c16f06af16a0f05945b4a92a

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