Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

A python function opens file data.csv, reads the data from the file and spits the data into three columns, x, y and z. The data is then printed out.

Function:

f = open("data.csv ", "r")

print('x\ty\tz'.format())

for row in f:

    temp = row.split(',')

    for cell in temp:

        print(cell,end='\t')

    print()

 

data.csv contains:

1.2,2.1,1.1

2.3,3.2,0.6

0.7,1.9,0.1

1.8,2.5,0.3

4.6,2.7,0.9

Write a function write_csv_file that will compute the square of each of these values
and write out a new file called output.txt that contains the new data. Ensure that both
the input and output data have the same format (i.e. both are comma separated variable files)
and that the output numbers are written to 3 decimal places. Verify that the output is correct
by read csv file to read in the data, and print the new data out.
expand button
Transcribed Image Text:Write a function write_csv_file that will compute the square of each of these values and write out a new file called output.txt that contains the new data. Ensure that both the input and output data have the same format (i.e. both are comma separated variable files) and that the output numbers are written to 3 decimal places. Verify that the output is correct by read csv file to read in the data, and print the new data out.
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education