How can I read this CSV #2252
Unanswered
lucasrochadejesus
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi guys, I'm using the version CSVHelper 30.0.1 and worked fine for all CSV's but now I got a terrible CSV file..
I've tried to add at configuration:
Quote = '"', Escape = '"', Mode = CsvMode.NoEscape
tried: Mode = CsvMode.Escape, Mode = CsvMode.NoEscape and Mode = CsvMode.RFC4180 and I receive inventories = 0 items..
lineInventory.csv
ProductCode,Brand,Description,Stock,StockOther,,"",,
1231234123123-123123123,Item Wheel Components,"28 CHROME MOD *NO RIVETS 1x4 5x114.3 CHROME ",0,0
1231234123123-123123123,Item Wheel Components,"28 CHROME MOD *NO RIVETS 1x4 5x114.3 CHROME ",0,0
var inventories = GetRecords<lineItem, lineItemMap>(file).ToList();
` internal IEnumerable GetRecords<T, TMap>(string filename, string delimeter = ",", bool hasFrenchChars = false, bool hasHeader = true)
where T : class
where TMap : ClassMap
{
int countSkips = 1;
int headerCount = 0;
int countHeader = 0;
}`
`public class lineItem {
}`
` public class lineItemMap : ClassMap
{
public lineItemMap()
{
}`
Edit: I just walk around and disconsider header and read by index and added:
Map(m => m.Description).Index(2).TypeConverterOption.NullValues(""");
But would be great to know if it's possible to use Map HeaderName in this case too..
Beta Was this translation helpful? Give feedback.
All reactions