-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Question: How can I generate CSV without header and control the default value of Integer? #1288
Comments
updating FooMap also didn't work. |
csv.Configuration.HasHeaderRecord = false;
public class Foo
{
public int Id { get; set; }
public int? key { get; set; }
public int? key2 { get; set; }
public string str { get; set; }
public string Name { get; set; }
public string Version { get; set; }
public Guid? guid { get; set; }
}
|
Thank you so much. It resolved my #2 issue. |
I updated my response to answer your first question. I'm not quite sure what you are trying to do with question # 3. Trying to use the converter outside of CsvHelper is not going to work. It needs the 2nd two options you have set to null. |
Thanks once again. For question 3: In my code, I often need to convert string to byte [] and vice versa (As i store my data in DB as byte[]. and display data in string) So currently I am using Encoding.UTF8.GetBytes() or Encoding.UTF8.GetString() for conversions. I was wondering if CSVHelper has any type conversion method that performs better than what I am using now. |
I'm looking at the code and my other statement was incorrect. You can use it as your code suggests, you don't need the other two parameters. The problem is that it only appears to convert from Base64 strings or Hex strings. public override object ConvertFromString( string text, IReaderRow row, MemberMapData memberMapData )
{
if( text != null )
{
return ( options & ByteArrayConverterOptions.Base64 ) == ByteArrayConverterOptions.Base64
? Convert.FromBase64String( text )
: HexStringToByteArray( text );
}
return base.ConvertFromString( text, row, memberMapData );
} ByteArrayConverter link. |
Thank you for saving my day. It helped a lot. |
I am trying to create CSV string, But I am facing few issues.
`
private static void writeDataTest()
{
var records = new List
{
new Foo { Id = 1, Name = "one" },
new Foo { Id = 2, Name = "two" },
new Foo { Id = 3, Name = "three" },
};
I am getting the output string s as
But I want the output as follows
var converter = new ByteArrayConverter(ByteArrayConverterOptions.None); var result = converter3.ConvertFromString("abc", null, null);
The text was updated successfully, but these errors were encountered: