<commit_before>from __future__ import print_function
import  sys
from googleapiclient.discovery import build
import json
import requests
import os
from google.oauth2 import service_account
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
import pickle

SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']
# The ID and range of a sample spreadsheet.
SAMPLE_SPREADSHEET_ID = sys.argv[1] # '1JZ-DHyl8D-RbudM8J0fZADXTElWvw6ilQTyncGDPEbs'
SAMPLE_RANGE_NAME = 'xsr!A6:D'
url = "https://us-central1-%s.cloudfunctions.net/addTranslations" % sys.argv[2]
client_secret = sys.argv[3]


def main():
    """Shows basic usage of the Sheets API.
    Prints values from a sample spreadsheet.
    """
    creds = None
    # The file token.pickle stores the user's access and refresh tokens, and is
    # created automatically when the authorization flow completes for the first
    # time.
    if os.path.exists('token.pickle'):
        with open('token.pickle', 'rb') as token:
            creds = pickle.load(token)
    # If there are no (valid) credentials available, let the user log in.
    if not creds or not creds.valid:
        if creds and creds.expired and creds.refresh_token:
            creds.refresh(Request())
        else:
            flow = InstalledAppFlow.from_client_secrets_file(
                client_secret, SCOPES)
            creds = flow.run_local_server(port=0)
        # Save the credentials for the next run
        with open('token.pickle', 'wb') as token:
            pickle.dump(creds, token)

    service = build('sheets', 'v4', credentials=creds)

    # bucket = storage.bucket()
    # Use a service account
    firebase_admin.initialize_app()

    db = firestore.client()

    # Call the Sheets API
    sheet = service.spreadsheets()
    result = sheet.values().get(spreadsheetId=SAMPLE_SPREADSHEET_ID,
                                range=SAMPLE_RANGE_NAME).execute()
    values = result.get('values', [])

    if not values:
        print('No data found.')
    else:
        for row in values:
            # Print columns A and E, which correspond to indices 0 and 4.
            if (len(row) == 4):
                english_word = row[0]
                primary_word = row[1]
                frequency = row[2]
                translation = row[3]  
                transliteration = ''
                sound_link = ''
                x = {
                      "english_word": english_word.lower(),
                      "primary_word": primary_word.lower() if primary_word != "PLACEHOLDER" else '',
                      "translation": translation.lower(),
                      "frequency": frequency,
                      "transliteration": transliteration,
                      "sound_link": sound_link
                    }<commit_msg>add words without translations<commit_after>from __future__ import print_function
import  sys
from googleapiclient.discovery import build
import json
import requests
import os
from google.oauth2 import service_account
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
import pickle

SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']
# The ID and range of a sample spreadsheet.
SAMPLE_SPREADSHEET_ID = sys.argv[1] # '1JZ-DHyl8D-RbudM8J0fZADXTElWvw6ilQTyncGDPEbs'
SAMPLE_RANGE_NAME = 'xsr!A6:D'
url = "https://us-central1-%s.cloudfunctions.net/addTranslations" % sys.argv[2]
client_secret = sys.argv[3]


def main():
    """Shows basic usage of the Sheets API.
    Prints values from a sample spreadsheet.
    """
    creds = None
    # The file token.pickle stores the user's access and refresh tokens, and is
    # created automatically when the authorization flow completes for the first
    # time.
    if os.path.exists('token.pickle'):
        with open('token.pickle', 'rb') as token:
            creds = pickle.load(token)
    # If there are no (valid) credentials available, let the user log in.
    if not creds or not creds.valid:
        if creds and creds.expired and creds.refresh_token:
            creds.refresh(Request())
        else:
            flow = InstalledAppFlow.from_client_secrets_file(
                client_secret, SCOPES)
            creds = flow.run_local_server(port=0)
        # Save the credentials for the next run
        with open('token.pickle', 'wb') as token:
            pickle.dump(creds, token)

    service = build('sheets', 'v4', credentials=creds)

    # bucket = storage.bucket()
    # Use a service account
    firebase_admin.initialize_app()

    db = firestore.client()

    # Call the Sheets API
    sheet = service.spreadsheets()
    result = sheet.values().get(spreadsheetId=SAMPLE_SPREADSHEET_ID,
                                range=SAMPLE_RANGE_NAME).execute()
    values = result.get('values', [])

    if not values:
        print('No data found.')
    else:
        for row in values:
            # Print columns A and E, which correspond to indices 0 and 4.
            if (len(row) == 4):
                english_word = row[0]
                primary_word = row[1]
                frequency = row[2]
                translation = row[3]  
                transliteration = ''
                sound_link = ''
                x = {
                      "english_word": english_word.lower(),
                      "primary_word": primary_word.lower() if primary_word != "PLACEHOLDER" else "",
                      "translation": translation.lower() if translation != "PLACEHOLDER" else "",
                      "frequency": frequency,
                      "transliteration": transliteration,
                      "sound_link": sound_link
                    }
{'fraction_non_alphanumeric': 0.09037261844545608, 'fraction_numerical': 0.006744225257123588, 'mean_word_length': 2.3590033975084936, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '330432', 'n_tokens_mistral': 1757, 'n_tokens_neox': 1670, 'n_words': 471}