Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CsvColumn FieldIndex does not respect position when parsing a file #26

Open
adamfisher opened this issue Aug 14, 2014 · 1 comment
Open

Comments

@adamfisher
Copy link

I am attempting to process a file that contains five columns:

Column1,Column2,Column3,Column4,Column5

I only want to grab certain columns but LinqToCSV errors out when it attempts to parse the file because Column1 is a string and Column2 is an int. The file does not contain headers so I would expect I could just specify the FieldIndex and it would grab from the correct position. My model is like such:

public class Foo {
[CsvColumn(FieldIndex = 2)]
public int Id;
}

So I would expect Column2 data to appear in the Id property but LinqToCSV tries to place Column1 data in Id. It looks like it is purely used for ordering the columns but they still all need to be present. It would be nice if the FieldIndex actually correlated to the position of the data we wish to store in our model.

@mperdeck
Copy link
Owner

Would it be possible to grab all 5 columns, and then select the ones you want using LINQ .Select?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants