Awesome Python Scripts
<p>Higuys! Today I want to share with you some useful scripts for python.<br />
I am a big fan of scripts, because they facilitate routine work, improve projects, as well as give a visual representation of the use of knowledge in practice</p>
<p>Let’s go!</p>
<p><img alt="" src="https://miro.medium.com/v2/resize:fit:630/1*5wfVRjG3XQSVlOaA601YZg.jpeg" style="height:525px; width:700px" /></p>
<h2>1. Convert JSON to CSV</h2>
<pre>
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)}')</pre>
<h2>2. Password Generator</h2>
<pre>
import random
import string
total = string.ascii_letters + string.digits + string.punctuation
length = 16
password = "".join(random.sample(total, length))
print(password)</pre>
<p><a href="https://medium.com/@dmitrijkumancev571/awesome-python-scripts-6711873a35c3">Website</a></p>