🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

"read in csv file skip first n lines"

josef_frankUser: "josef_frank"
New Altair Community Member
Updated by Jocelyn

Hi,

when importing csv files, is there any method to skip lines in the beginning of a file?
Something that behaves like R's "read.table"-option "skip".

Quite some time I'd like to read in csv files that have a structure like windows' ini-files:

[Header]
some garbage here
some non-relevant info here
[Data]
Var1,Var2,Var3,...
0,1,0,...
....

I'd like to start reading the file in the line "Var1,Var2,.."
Just can't find any option to get this done :-(

Best
Josef

Find more posts tagged with

Sort by:
1 - 1 of 11
    Telcontar120User: "Telcontar120"
    New Altair Community Member
    Accepted Answer

    @sgenzer So Martin posted a comment in the related product idea that I think showed me the solution.  You can use the "Edit Annotations" parameter to manually specify that certain lines are to be treated as comments (even if they don't have the comment character, which is where I was getting hung up before).  See the following:

    annotations.PNG

    That effectively skips those lines on import and it starts reading on the specified line, and interprets the correct number of columns!  And at that point, the extra work with the macros to rename the attributes isn't needed either, since you can specify the relevant line to be read as names--but I'm sure going to save that process anyways because it could come in handy in other more complex data files in the future.  Thanks again!