Naveen is owning an electronics shop. He has an XML file that contains all the products that is present in his shop. He wants to tabulate his items in the excel. He found out that a CSV file can be easily represented as an excel. Write a program to help naveen by reading an XML file and printing it in CSV format with heading.
click here to download the XML file
Input Format:
Input is a XML file. (file name should be product.xml). The file is already been created in the platform.
Example:
<productList>
<product>
<id>1</id>
<productName>Mobile</productName>
<cost>6000</cost>
<weight>200</weight>
</product>
<product>
<id>2</id>
<productName>Laptop</productName>
<cost>60000</cost>
<weight>2000</weight>
</product>
</productList>
Output Format:
Print the data in CSV format which is in XML file.(file name should be product.csv)
Example:
id,productName,cost,weight
1,Mobile,6000,200
2,Laptop,60000,2000
file=open("File.xml", 'r')
message = "id,productName,cost,weight\n"
for data in file:
if data.strip().__contains__("<id>"):
message+=data.strip().split(">")[1].split("<")[0]
if data.strip().__contains__("<productName>"):
message += ","+data.strip().split(">")[1].split("<")[0]
if data.strip().__contains__("<cost>"):
message += ","+data.strip().split(">")[1].split("<")[0]
if data.strip().__contains__("<weight>"):
message += "," + data.strip().split(">")[1].split("<")[0]+"\n"
fw=open("product.csv",'w')
fw.write(message)
fw.close()
file.close()
#save File.xml with this data given below and then run the program
'''<productList>
<product>
<id>1</id>
<productName>Mobile</productName>
<cost>6000</cost>
<weight>200</weight>
</product>
<product>
<id>2</id>
<productName>Laptop</productName>
<cost>60000</cost>
<weight>2000</weight>
</product>
</productList>'''
In Python and in one file please. (Simple functions with an expressions) Create a function called load_inventory(filename). The filename argument in this case specifies the name of a file that contains all the inventory/product information for the store, including product names, descriptions, prices, and stock levels. This function should clear any information already in the product list (i.e., a fresh start) and then re-initialize the product list using the file specified by the filename argument. You can structure your file...
In Python and in one file please. (Simple functions with an expressions) Create a function called load_inventory(filename). The filename argument in this case specifies the name of a file that contains all the inventory/product information for the store, including product names, descriptions, prices, and stock levels. This function should clear any information already in the product list (i.e., a fresh start) and then re-initialize the product list using the file specified by the filename argument. You can structure your file...
Don't attempt if you can't attempt fully, i will dislike a nd negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book tit le, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an...
Don't attempt if you can't attempt fully, i will dislike and negative comments would be given Please it's a request. c++ We will read a CSV files of a data dump from the GoodReads 2 web site that contains information about user-rated books (e.g., book titnle, publication year, ISBN number, average reader rating, and cover image URL). The information will be stored and some simple statistics will be calculated. Additionally, for extra credit, the program will create an HTML web...
the OOP project is needed to be coded in netbeans and store a information in file on local machine it could be stored with xml tags since its easier. OOP Project Description Requirements: You are to design and build software media rental system. The software will track each user’s account with its rentals. A user can rent multiple media of different type/genre and all that user’s rentals are managed under their account (single account per user). A user will be...
Using Python... Be sure to include the first line that makes the file an executable file in Linux. File Name: PyramidBlocks.py Python skills needed: Simple for loop (for var in range(num1,num2): Use of the range object Use of python math Creation of a Python Function Use of the print() method. Code Assignment 1: Alex sells pyramid wall art. In the design of his pyramids have each row has one more block than the last which means row 10 has 10...
23.4 Project 4: Using Pandas for data analysis and practice with
error handling
Python Please!
23.4 PROJECT 4: Using Pandas for data analysis and practice with error handling Overview In this project, you will use the Pandas module to analyze some data about some 20th century car models, country of origin, miles per gallon, model year, etc. Provided Input Files An input file with nearly 200 rows of data about automobiles. The input file has the following format (the same...
Requires Python to answer
A client wishes to keep track of his investment in shares. Write a program to help him manage his stock portfolio. You are to record both the shares that he is holding as well as shares that he has sold. For shares be is curreatly holding, record the following data: .a 3-character share code, share name, last purchase date, volume currently held and average purchase price (refer to description under part cii) option 2) For shares...
Project 3 Instructions 1. Due Date & Time: 09-26-2020 at 11:59 PM WHAT TO SUBMIT Submit 1 zip file containing 4 files below to iLearn by the deadline. [30 points] ● 3 JAVA Files: TableBmiPro.java, MyOwnIdea.java. DiceRoll.java [24 points] ● 1 File: Make a document that shows the screen captures of execution of your programs and learning points in Word or PDF. Please make sure you capture at least 2 executions for 1 program, so 6 screen captures and one...
Bexter Labs produces three products: A, B, and C. Bexter can
sell up to 2000 units of Product A, up to 3000 units of Product B,
and up to 5000 units of Product C. Each unit of Product C uses two
units of A and three units of B and incurs $7 in processing costs.
Products A and B are produced from either raw material 1 or raw
material 2. It costs $9 to purchase and process one unit of...