Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions projects/Convert_JSON_to_CSV/converter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import json

if __name__ == '__main__':
try:
with open('input.json', 'r') as f:
data = json.loads(f.read())

output = ','.join([*data[0]])
for obj in data:
output += f'\n{obj["Name"]},{obj["age"]},{obj["birthyear"]}'

with open('output.csv', 'w') as f:
f.write(output)
except Exception as ex:
print(f'Error: {str(ex)}')
12 changes: 12 additions & 0 deletions projects/Convert_JSON_to_CSV/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"Name": "Akash",
"age": 26,
"birthyear": "1994"
},
{
"Name": "Abhay",
"age": 34,
"birthyear": "1986"
}
]
3 changes: 3 additions & 0 deletions projects/Convert_JSON_to_CSV/output.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Name,age,birthyear
Akash,26,1994
Abhay,34,1986
48 changes: 48 additions & 0 deletions projects/Random password generator/random_password_gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import random
import math
alpha="abcdefghijklmnopqrstuvwxyz"
num="0123456789"
special="@#$%&*"

#pass_len=random.randint(8,13) #without User INput
pass_len=int(input("Enter Password Length"))

#length of password by 50-30-20 formula
alpha_len=pass_len//2
num_len=math.ceil(pass_len*30/100)
special_len=pass_len-(alpha_len+num_len)


password=[]

def generate_pass(length,array,is_alpha=False):

for i in range(length):
index=random.randint(0,len(array)-1)
character=array[index]
if is_alpha==True:

case=random.randint(0,1)
if case==1:
character=character.upper()

password.append(character)

#alpha password
generate_pass(alpha_len,alpha,True)
#numeric password
generate_pass(num_len,num)
#special Character password
generate_pass(special_len,special)

#suffle the generated password list
random.shuffle(password)

#convert List To string
gen_password=""
for i in password:
gen_password=gen_password+str(i)

print(gen_password)


24 changes: 0 additions & 24 deletions projects/Random_word_from_list/Random_word_from_list.py

This file was deleted.

Loading