2021-04-29 12:33:46 +02:00
|
|
|
from pandas import read_table
|
|
|
|
|
|
|
|
|
|
|
|
def read_header(filename):
|
|
|
|
with open(filename, "r") as f:
|
|
|
|
header = f.readline().split()
|
2021-05-03 18:00:18 +02:00
|
|
|
return int(header[0])
|
2021-04-29 12:33:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
def parse_file(filename):
|
2021-05-03 18:00:18 +02:00
|
|
|
n = read_header(filename)
|
|
|
|
m = 50
|
2021-04-29 12:33:46 +02:00
|
|
|
df = read_table(
|
|
|
|
filename, names=["source", "destination", "distance"], sep=" ", skiprows=[0]
|
|
|
|
)
|
|
|
|
return n, m, df
|