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.5.tar.gz
(8.4 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.5-py3-none-any.whl
(11.1 kB
view details)
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1596fef762c3bcd77393e4f6f2335bee2c145898a597ee8c06f2716195503894
|
|
| MD5 |
1688393402fe4d54129ba9149ecf30e3
|
|
| BLAKE2b-256 |
2c52fd5c0db83a82acdf97670976712c8f555f0100b22ffef3063734b24147c1
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
692a98008b7ef358ca005df12a4235eb47c24d26022930c8af3e41acbc00df84
|
|
| MD5 |
13cc780fe58253501536ea62e8bfef91
|
|
| BLAKE2b-256 |
6d707f937c9046dce01809f27a70f646562a2861c16f06af16a0f05945b4a92a
|