I created a script to check if English is entered in the specified position of the JSON file in Python.

Hi, this is Takumi.

I'm an engineer living in Osaka. (Strictly from 3/15) I'm currently studying Laravel / React. I will write Qiita for the first time this time, please be kind to me w

How it was created

Shohei, who is indebted to me, is making an app for learning English, so it's a private matter, but from my experience of studying English in the Philippines and teaching English at an elementary school, here We are happy to help you create English content for your app.

Click here for the app ↓ image.png

・ IOS https://apps.apple.com/jp/app/id1493691416

・ Android https://play.google.com/store/apps/details?id=com.gmail.hukusuke1007.lala

A little promotion w

My role is to enter English and Japanese into a JSON file, which is a very simple task, but I'm distracted and I always get the wrong place to write English and Japanese.

When I was wondering how to solve it, why not write a script? I got advice and decided to challenge.

スクリーンショット 2020-03-07 14.41.32.png

Code I wrote

script_check.py


import json
json_open = open('script.json', 'r', )
json_load = json.load(json_open)

checkWord1 = (json_load['title']['english'])
print(checkWord1)
print(checkWord1[0] .isupper()) 

checkWord2 = (json_load['description']['english'])
print(checkWord2)
print(checkWord2[0] .isupper()) 

sentences_check.py


import json
json_open = open('sentences.json', 'r', )
json_load = json.load(json_open)

num = 0
while (num < 10):
    print (json_load["sentences"][num]["text"]['english'])
    checkWord = (json_load["sentences"][num]["text"]['english'])
    print checkWord[0].isupper()
    num += 1

Overview

First of all, I wanted to take the JSON value with Python and judge it, so I referred to this article to get the value. Read JSON with Python

What is JSON in the first place! ?? I was in a state, so I studied from there w This site was easy to understand. Introduction to JSON

While I was investigating, I was told that JSON Schema could be used, but I stopped because it seemed to be difficult.

I found an article that summarizes functions that could be used, and decided to use isupper (). Alphanumeric judgment python

Execution result

スクリーンショット 2020-03-07 13.39.34のコピー.png

Like this, if Japanese is included, False will be returned.

Task

With this, you can check only one file, so it would be nice if you could create something to check if you specify a directory. After that, I want to color True and False in the terminal.

At the end

I will continue to study hard. We are holding a cloud meeting for scholars in Kansai, so please follow us if you like. Twitter

Recommended Posts

I created a script to check if English is entered in the specified position of the JSON file in Python.
I made a program to check the size of a file in Python
Create a python script to check if the link at the specified URL is valid 2
Create a python script to check if the link at the specified URL is valid
How to check in Python if one of the elements of a list is in another list
Check if the string is a number in python
I want to receive the configuration file and check if the JSON file generated by jinja2 is a valid JSON
I made a script in Python to convert a text file for JSON (for vscode user snippet)
I tried to create a Python script to get the value of a cell in Microsoft Excel
[Blender] Script to check if the selected one is a mesh
How to check the memory size of a variable in Python
How to check the memory size of a dictionary in Python
I made a function to check if the webhook is received in Lambda for the time being
What to do if there is a decimal in python json .dumps
Test & Debug Tips: Create a file of the specified size in Python
How to create a JSON file in Python
Various ways to read the last line of a csv file in Python
I made a script to record the active window using win32gui of Python
Template of python script to read the contents of the file
A memorandum to run a python script in a bat file
I want to randomly sample a file in Python
Python script to create a JSON file from a CSV file
What to do if the progress bar is not displayed in tqdm of python
Output the specified table of Oracle database in Python to Excel for each file
I want to initialize if the value is empty (python)
[python] How to check if the Key exists in the dictionary
Change the standard output destination to a file in Python
I made a function to check the model of DCGAN
[Note] Import of a file in the parent directory in Python
Get the value of a specific key up to the specified index in the dictionary list in Python
[OCI] Python script to get the IP address of a compute instance in Cloud Shell
[Python] Programming to find the number of a in a character string that repeats a specified number of times.
How to check if the contents of the dictionary are the same in Python by hash value
Python> __init__.py> Required to handle the specified directory as a package (empty file is acceptable)
I wrote a doctest in "I tried to simulate the probability of a bingo game with Python"
A Python script that allows you to check the status of the server from your browser
[Python] About creating a tool to display all the pages of the website registered in the JSON file & where it got caught
Process the contents of the file in order with a shell script
How to determine the existence of a selenium element in Python
Check if the configuration file is read in an easy-to-understand manner
Conditional branch due to the existence of a shell script file
I created a Python library to call the LINE WORKS API
Create a shell script to run the python file multiple times
Delete a particular character in Python if it is the last
I wrote the code to write the code of Brainf * ck in python
I wrote a function to load a Git extension script in Python
I wrote a script to extract a web page link in Python
I want to check the position of my face with OpenCV!
Check if you can connect to a TCP port in Python
[Golang] Check if a specific character string is included in the character string
Write a script in Shell and Python to notify you in Slack when the process is finished
I will publish a shell script created to reduce the trouble of creating LiveUSB on Linux
I found out by making a python script to record radiko while reading the code of the predecessors
I want to save the trouble of inputting when debugging Paiza's skill check example in a local environment such as Jupyter [Python]
What is the XX file at the root of a popular Python project?
If you want a singleton in python, think of the module as a singleton
How to send a visualization image of data created in Python to Typetalk
Check the existence of the file with python
Check if there is a specific symbol in the executable file and its dependent libraries (simplified version)
Check the in-memory bytes of a floating point number float in Python
Check if the URL exists in Python