get one specific line of comment as header with python Pandas
问题 I have a file looking like # Comment 1 # Comment 2 # A B C 1 2 3 4 5 6 7 8 9 How to read it with python pandas module, so as the last line of comments can be interpreted as the columns titles ? I've tried pandas.read_table(file_path, header= 2 , comment='#' ) But the comment lines are eliminated first, thus the header line will be 7 8 9 回答1: You can do this manually: first read the comments, parse the column names, then call read_table : import itertools import pandas as pd def read_data(path