MH-P2/src/preprocessing.py

17 lines
359 B
Python

from pandas import read_table
def read_header(filename):
with open(filename, "r") as f:
header = f.readline().split()
return int(header[0])
def parse_file(filename):
n = read_header(filename)
m = 50
df = read_table(
filename, names=["source", "destination", "distance"], sep=" ", skiprows=[0]
)
return n, m, df