Python question Complete without importing any modules Ie Do
Python question...
Complete without importing any modules. Ie. Don\'t import csv
Sample CSV:
file.csv containing:
first, last, age, height, weight, gender, lives
Jake, Cace, 24, 64,165, male, Spain
Jenny, Matte, 21, 58, 110, female, Italy
Solution
def csv():
print(\"CSV Data analysis\")
print()
fname = \"file.csv\" #inputing file name
#Reading the input file into a list with each row as a string
with open(fname) as f:
input_data = f.read().splitlines()
#initialising data
data = []
#iterating through the list containing input data and storing each row as a list of floats.
print (input_data)
for i in range(1, len(input_data)):
row_data = [x for x in input_data[i].split(\',\')]
data.append(row_data)
return data
print(csv())
