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
- Create a virtual environment (recommended to isolate dependencies):
python3 -m venv .venv
- Install Sheetrika inside the virtual environment:
.venv/bin/pip install sheetrika
2. Enable Google Sheets API
- Go to the Google Cloud Console API Library.
- Search for
Google Sheets API. - Click Enable to activate the API for your project.
3. Create a Service Account
- Navigate to the Google Cloud Console Credentials page.
- Click Create Service Account and follow the prompts.
- In the Service Account settings, go to the Keys tab and click Add Key → JSON. Save the file as
creds.json. - Encode the credentials for secure use:
.venv/bin/sheetrika encode creds.json
- Copy the output and save it to a new
.envfile. Example:export GOOGLE_API_TOKEN="your_encoded_token_here"
4. Configure Demo Parameters in config.yml
- Google Spreadsheet Setup:
- Create a new spreadsheet or open an existing one.
- Extract the
spreadsheet_idfrom the URL:https://docs.google.com/spreadsheets/d/{spreadsheet_id}/edit - Add the
client_emailfromcreds.jsonto the spreadsheet’s sharing permissions (as an editor).
- Yandex Metrica Parameters:
- Refer to the Yandex Metrica Documentation for query 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
- Follow the Yandex Metrica Authorization Guide to obtain a token.
- Save the token to your
.envfile: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)
snapshot: Clears all data in the specified range and writes new data.append: Finds the first empty row and appends data below it.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.jsonand.envfiles out of version control (add them to.gitignore). - Debugging: If permissions fail, ensure the
client_emailhas edit access to the spreadsheet.
Let me know if you'd like further refinements!
Project details
Release history Release notifications | RSS feed
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.4.tar.gz
(10.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
sheetrika-0.1.4-py3-none-any.whl
(10.8 kB
view details)
File details
Details for the file sheetrika-0.1.4.tar.gz.
File metadata
- Download URL: sheetrika-0.1.4.tar.gz
- Upload date:
- Size: 10.2 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
053c200551418479b9568f144d126485a9707adca32a184261b54e1a2ca7d8a7
|
|
| MD5 |
2efe2fa4fd78056bec213b0856b9d1b3
|
|
| BLAKE2b-256 |
c5655abd5696d4188099077c8e144acdec6835b98b345c92ba083585aaaa6700
|
File details
Details for the file sheetrika-0.1.4-py3-none-any.whl.
File metadata
- Download URL: sheetrika-0.1.4-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f283b17e781a370e1974bbabdf1194c0915f244e2fd6f88b647d78a7ef685b0a
|
|
| MD5 |
b77b62ed907cd9e7f8643776e9baad19
|
|
| BLAKE2b-256 |
88bf8863b91c4561d19380c8daa78db9cbc0415b927d7f863f5ef215ad7b74fd
|