File size: 1,285 Bytes
48cb310
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import sys
import subprocess
import os
import keyfiledict
import gspread
from oauth2client.service_account import ServiceAccountCredentials
from google.oauth2 import service_account

from dotenv import load_dotenv

load_dotenv()

# Upgrade pip
subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "pip"])

# Check if the venv module is available
if sys.version_info >= (3, 3):
    subprocess.run([sys.executable, "-m", "venv", "venv"])
else:
    subprocess.run(["python", "-m", "venv", "venv"])


    # Activate the virtual environment
    activate_script = os.path.join("venv", "Scripts", "activate")
    subprocess.run(activate_script, shell=True)

subprocess.check_call(["pip", "install", "google-api-python-client"])

# Install oauth2client
subprocess.check_call(["pip", "install", "oauth2client"])
subprocess.check_call(["pip", "install", "gspread"])


# credentials file downloaded from Google Developers Console

client = gspread.authorize(keyfiledict.credentials())
sheet = client.open('Zapotec Minimal Pairs').sheet1

# Get all values from the sheet
list_of_data = sheet.get_all_records()

# Get a range of cells
cells = sheet.range('C2:C32')
for cell in cells:
    print(cell.value)

#print(list_of_data)