Implement file parsing
This commit is contained in:
parent
09caafc2cf
commit
46efa13c5b
|
@ -0,0 +1,24 @@
|
||||||
|
from sys import argv
|
||||||
|
from pandas import read_table
|
||||||
|
|
||||||
|
|
||||||
|
def read_header(filename):
|
||||||
|
with open(filename, "r") as f:
|
||||||
|
header = f.readline().split()
|
||||||
|
return header[0], header[1]
|
||||||
|
|
||||||
|
|
||||||
|
def parse_file(filename):
|
||||||
|
n, m = read_header(filename)
|
||||||
|
df = read_table(
|
||||||
|
filename, names=["source", "destination", "distance"], sep=" ", skiprows=[0]
|
||||||
|
)
|
||||||
|
return n, m, df
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parse_file(argv[1])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in New Issue