math_marks_A = []for line in open("Desktop\student_record.txt"): fields = line.split(";") region_code = fields[0] region_code_stripped = region_code.strip() math_mark_str = fields[5] math_mark = float(math_mark_str) if region_code == "A": math_marks_A.append(math_mark)#make sure to save this in notepad as .py file.# Most of people make error in specifying student_record.txt folder destination.# Execute %run Desktop\marks.py command in ipython3.
5540 visits
Outline: Parsing data explain what is parsing strip (with strings) split (with strings) with delimiters specify space as delimiter datatype conversion reading from files do the same problem done with loadtxt (for pendulum) basic parse sslc text
Parsing data explain what is parsing strip (with strings) split (with strings) with delimiters specify space as delimiter datatype conversion reading from files do the same problem done with loadtxt (for pendulum) basic parse sslc text
Show video info
Pre-requisite