오늘의 인기 글
최근 글
최근 댓글
Today
Total
05-03 06:06
관리 메뉴

우노

[Python] file read 시 head 제거 본문

Language/Python

[Python] file read 시 head 제거

운호(Noah) 2020. 11. 30. 13:33

file read 시 head 제거

  • 기존 데이터

      # Undirected graph: ../../data/output/dblp.ungraph.txt
      # DBLP
      # Nodes: 317080 Edges: 1049866
      # FromNodeId    ToNodeId
      0    1
      0    2
      ...
  • read 시 head 제거

      with open(inputfile,"r") as rf:
    
          # 첫 4줄(head) 제거
          for i in range(4):
              next(rf)
    
          # head 이후부터 읽기
          for i in rf:
              print(i)
      0    1
      0    2
      ...
Comments