<jupyter_start><jupyter_text>Detecting language<jupyter_code>import os
import csv
import pandas as pd
from google.cloud import translate_v2<jupyter_output><empty_output><jupyter_text>The file path to save the data allocated according to the language selection<jupyter_code>filePath=r"C:\Users\User\Desktop\youtubeScraper"<jupyter_output><empty_output><jupyter_text>File path where the Natural Language API key is located<jupyter_code>os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = r'C:\Users\User\Desktop\youtubeScraper\key.json'
translate_client = translate_v2.Client()<jupyter_output><empty_output><jupyter_text>File path of the data we pull with youtubeScraper<jupyter_code>df = pd.read_csv (r'C:/Users/User/Desktop/youtubeScraper/rpERSigjqXs.csv',encoding='utf-8', error_bad_lines=False )
df['Comment'][0]
with open(filePath+"/"+"turkish.csv", mode='w', newline='') as newFile:
        newWriter = csv.writer(newFile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) 
        newWriter.writerow(['Comment'])
        newFile.close()
text=[]
for k in range(len(df)):
    try:
        text.append(df['Comment'][k])
    except:
        pass
for i in range(len(text)):
    try:
        inputString=(text[i])
        result=translate_client.detect_language(inputString)
        if result['language']=="tr":
            with open(filePath+"/"+"turkish.csv", mode='a', newline='') as newFile:
                                newWriter = csv.writer(newFile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) 
                                newWriter.writerow([inputString])
                                newFile.close()
    except:
        pass<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13159454653230587, 'fraction_numerical': 0.0023710729104919974, 'mean_word_length': 4.053892215568863, 'pattern_counts': {'":': 1, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '200518', 'license': 'MIT', 'n_tokens_mistral': 570, 'n_tokens_neox': 547, 'n_words': 95, 'path': 'detectingLanguage.ipynb', 'repo_name': 'umutsrgncn/youtubeScraperAndSentimentAnalysis', 'size': '1687'}