PWP MicroProject
PWP MicroProject
This is to certify that Students of CO6I (S.V.M., R.A.G., S.P.A.) Roll no.:16,
33, 34 of SIXTH Semester of Diploma in Computer Engineering of Institute,
Government Polytechnic, Jalgaon (Code:0018) has completed the Micro
Project satisfactorily in the Subject – Programming with Python for the
Academic Year 2021- 2022 as prescribed in the curriculum.
Place: Jalgaon
Date: / /
Seal of
Institution
GOVTERNMENT POLYTECHNIC
JALGAON
-SUBMISSION-
We the Students of CO6I (S.V.M., R.A.G., S.P.A.) Roll No. 16, 33, 34
as students of SIXTH Semester of the Programme Computer Engineering
humbly submit that we have completed from time to time the Micro-Project
work as described in this report by our own skills and study between the period
from ________ 2022 to ______ 2022. As per instructions/guidance of
Rupali Ma’am and those following students were associated with us for this
work, however, quantum of our contribution has been approved by the Lecturer.
And that we have not copied the report on its any appreciable part from
any other literature in contravention of the academic ethics.
16.
33.
34.
Sr. Detail of activity Plan start Plan finish Name of responsible team members
No. date date
1 Group discussion 1]SHRUTIKA VITTHAL
2 Searching of real life task MAHAJAN.
1.0 Rationale
To study the concepts of Python packages
Report preparation
Introduction :
In this micro project, we have implemented the menu driven programming,
where user can use 2 Internet Media Converters between 3 given options as
follows :-
1. Convert XML to JSON
2. Convert JSON to XML
3. Exit
In option-1 user has to give XML file as input with the name of .JSON file,
here after conversion from .XML to .JSON, .JSON code is shown to user and
that same data is stored in the given .JSON file . We have used xmltodict
library for data conversion. We have also handled exception if the input .XML
file is not available or if the given extension is invalid.
In option-2 user has to give JSON file as input with the name of .XML file,
here after conversion from .JSON to .XML, .XML code is shown to user and
that same data is stored in the given .XML file. We have used dict2xml
library for data conversion. We have also handled exception if the
input .JSON file is not available or if the given extension is invalid.
If user selects option-3, the program terminates with the”Bye Bye” message,
otherwise the program executed repeatedly (Menu Driven)
Code :
import numpy as np
import json
import xmltodict
from dict2xml import dict2xml
while True:
print("\n\n------------------------")
print("$$$$ CONVERSION MENU $$$$");
print("1.Convert XML to JSON")
print("2.Convert JSON to XML")
print("3.Exit")
print("------------------------")
Choice=int(input("Your choice "))
if Choice==1:
n = input('Enter the the file name ')
try:
with open(n) as xml_file:
try:
parsed_data = xmltodict.parse(xml_file.read())
xml_file.close()
except:
print("File error")
continue
except:
print("File not found")
continue
json_conversion = json.dumps(parsed_data)
opfile=input("Enter output json filename: ")
with open(opfile, 'w') as json_file:
json_file.write(json_conversion)
json_file.close()
elif Choice==2:
n = input('Enter the the file name ')
try:
with open(n) as json_format_file:
try:
d = json.load(json_format_file)
except:
print("File error")
continue
except:
print("File not found")
continue
xml=dict2xml(d)
opfile = input("Enter output json filename")
with open(opfile, 'w') as xml_file:
xml_file.write(xml)
xml_file.close()
print("The xml file is :")
with open(opfile, 'r') as file:
for line in file:
print(line,end="")
file.close()
elif Choice==3:
print("Bye Bye")
exit()
else:
print("Oops! Invalid Choice")
Output:
Conclusion
Thus, we have successfully created an the program for File conversion
(XML to JSON & JSON to XML).Our program gives convenience to those
who want to write data in both formats i.e in XML and JSON, so instead of
writing both of them from scratch, the person can write any one who he is
best at, and then convert it to other extension file which saves his time and
efforts.
While doing this project, we have gain a very good practical knowledge of
Python.