I have a data csv file with first few rows are storing information.The format is like this:info1, aainfo2, bbinfo3, cccol1,col2, col3x1, y1,z1x2, y2,z2If I use numpy.genfromtxt(), it will show error due to different columns between first three lines, and the rest.I can use numpy.genfromtxt(skip_header=3) to read the data, and numpy.genfromtxt(skip_footer= ) to read the information.I wonder if there is a better way to do this?
You have a working method with only two lines of code.What would you consider better?
if by "better" you mean more dynamically read out different types of rows, then you may open and iterate the CSV and process it line by line, as long as you have fixed patterns to extract, for example, two columns means information, three columns means data.
How would you want this output to look like? Two arrays? Two dat frames? Everything together in a data frame with NaNs filling the missing spaces?
It just feels like need to open the file twice. I am thinking that read in the file one time, and then do further processing.