8000 Scripts · techiescamp/python-for-devops@8d83984 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d83984

Browse files
committed
Scripts
1 parent 355c6f3 commit 8d83984

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

json/example.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name" : "test",
3+
"ip" : "198.168.23.45",
4+
"country" : "United States",
5+
"project" : "Data Analytics",
6+
"website" : "scriptscrunch.com"
7+
}

json/parse-json.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import json
2+
import os
3+
4+
# Script to create absolute path of the JSON file.
5+
6+
script_dir = os.path.dirname(__file__)
7+
print("The Script is located at:" + script_dir )
8+
script_absolute_path = os.path.join(script_dir, 'example.json')
9+
print("The Script Path is:" + script_absolute_path)
10+
11+
# Script to parse JSON
12+
13+
json = json.loads(open(script_absolute_path).read())
14+
value = json['name']
15+
print(value)
16+
17+
# Loop through JSON
18+
19+
for key in json:
20+
value = json[key]
21+
print("The key and value are ({}) = ({})".format(key, value))
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import os
2+
3+
# 1. Create Directory
4+
# 2. Delete Directory
5+
# 3. List Directory
6+
# 4. List total number of folder in a Directory
7+
# 5. List total numbers of files in a Directory

operating-system/file-operations.py

Whitespace-only changes.

0 commit comments

Comments
 (0)
0