def remove7(path_number): with open("tmp.txt", 'w') as tmp: with open("Path#" + str(path_number) + ".txt", "r") as f: for line in f: if line.strip(): tmp_d = da.data_from_line(line) if tmp_d.sonar_id != 7: tmp.write(line) with open("tmp.txt", 'r') as tmp: with open("Path#" + str(path_number) + ".txt", "w") as f: for line in tmp: f.write(line) os.remove("tmp.txt")
def format_file(path_number): with open("tmp.txt", 'w') as tmp: with open("Path#" + str(path_number) + ".txt", "r") as f: for line in f: if line.strip(): tmp_d = da.data_from_line(line) if MIN_MEASURE < tmp_d.measure < MAX_MEASURE: tmp.write(line) with open("tmp.txt", 'r') as tmp: with open("Path#" + str(path_number) + ".txt", "w") as f: for line in tmp: f.write(line) os.remove("tmp.txt")
def extract_from_file(data, path_number): with open("Path#" + path_number + ".txt", "r") as f: for line in f: data.append(da.data_from_line(line)) return data