-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram 10.py
53 lines (46 loc) · 1.67 KB
/
Program 10.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#10A
#Fetch Weather Data from JSON
import json
def fetch_weather_data_from_json(file_path):
try:
with open(file_path, "r") as json_file:
weather_data = json.load(json_file)
return weather_data
except FileNotFoundError:
print(f"File not found: {file_path}")
except json.JSONDecodeError:
print(f"Invalid JSON format in the file: {file_path}")
except Exception as e:
print(f"Error occurred while reading the JSON file: {e}")
return None
if __name__ == "__main__":
file_path = "phyton zip file.json"
weather = fetch_weather_data_from_json(file_path)
if weather:
print("Current Weather Data:")
print(f"City: {weather['city']}")
print(f"Temperature: {weather['temperature']}°C")
print(f"Humidity: {weather['humidity']}%")
print(f"Conditions: {weather['conditions']}")
else:
print("Failed to fetch weather data from the JSON file.")
#10B
#A Merge multiple PDF into one New PDF file**
pip install PyPDF2
from PyPDF2 import PdfWriter, PdfReader
num = int(input("Enter page number you want combine from multiple documents "))
pdf1 = open('CIP unitwise qs.pdf', 'rb')
pdf2 = open("R Programming LabMannual.pdf", 'rb')
pdf_writer = PdfWriter()
pdf1_reader = PdfReader(pdf1)
page = pdf1_reader.pages[num - 1]
pdf_writer.add_page(page)
pdf2_reader = PdfReader(pdf2)
page = pdf2_reader.pages[num - 1]
pdf_writer.add_page(page)
with open('output.pdf', 'wb') as output:
pdf_writer.write(output)
'''output
Requirement already satisfied: PyPDF2 in c:\users\vasudha bhat\anaconda3\lib\site-packages (3.0.1)
Enter page number you want combine from multiple documents 3
'''