Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello again, writing a script in Python. I want to read a file by using def read_data_file, and then I want to print it in

Hello again, writing a script in Python.

I want to read a file by using def read_data_file, and then I want to print it in the screen and extract it on an output file. But after return I have a problem. I dont know how to define the variables and then print them (&extract them)

file_name="data.txt"

latitude=[]

longitude=[]

temperature=[]

def read_data_file(file_name): with open(filename) as infile: line = infile.readline() while True: line = infile.readline() if not line: break _ , lat, lon, temp, _ = line.split("|", maxsplit=5) latitude.append(lat) longitude.append(lon) temperature.append(temp) return latitude,longitude,temperature

What I though to do is (but doesn't work):

atitude,longitude,temperature = read_data_file(file_name)

Please some help with the code..

Thank you!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions

Question

4. Identify the challenges facing todays organizations

Answered: 1 week ago