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

Support CSV #14

Closed
shps951023 opened this issue Mar 3, 2021 · 9 comments
Closed

Support CSV #14

shps951023 opened this issue Mar 3, 2021 · 9 comments
Labels
enhancement New feature or request help wanted Extra attention is needed todo
Projects

Comments

@shps951023
Copy link
Member

shps951023 commented Mar 3, 2021

Why ExcelDataReader read csv need another method
image

image

@shps951023 shps951023 added enhancement New feature or request todo labels Mar 3, 2021
@shps951023 shps951023 added this to Not Important in MiniExcel Mar 14, 2021
@shps951023 shps951023 moved this from Not Important to In progress in MiniExcel Mar 16, 2021
@shps951023
Copy link
Member Author

ExcelDataReader read csv all string type defualt
image

@shps951023 shps951023 pinned this issue Mar 20, 2021
@shps951023 shps951023 added the help wanted Extra attention is needed label Mar 20, 2021
@shps951023
Copy link
Member Author

@shps951023
Copy link
Member Author

CsvHelper

void Main()
{
	var records = new List<Foo>
	{
		new Foo { Id = 1, Name = "one" },
		new Foo { Id = 2, Name = "two" },
	};
	var path =  Path.Combine(Path.GetTempPath(),$"{Guid.NewGuid().ToString()}.csv");
	using (var writer = new StreamWriter(path))
	using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
	{
		csv.WriteRecords(records);
	}
	Console.WriteLine(path);
}

// You can define other methods, fields, classes and namespaces here
public class Foo
{
	public int Id { get; set; }
	public string Name { get; set; }
}
Id,Name
1,one
2,two

@shps951023
Copy link
Member Author

LibreOffice Calc
image

@shps951023
Copy link
Member Author

image

input : 0 & "\"; ,"
ouput : 0,"""; ,"

@shps951023
Copy link
Member Author

csvhelper " convert to """"

@shps951023
Copy link
Member Author

image

System.IO.IOException : The process cannot access the file 'C:\Users\Wei\AppData\Local\Temp\c080ec8e-c38e-4971-be50-8663f312dbf6.csv' because it is being used by another process.

@shps951023
Copy link
Member Author


@shps951023
Copy link
Member Author

shps951023 commented Mar 25, 2021

Lazy loading will meet if using stream it'll dipose before lazy loading, so system will show

System.ArgumentException
  HResult=0x80070057
  Message=Stream was not readable.
  Source=System.Private.CoreLib
  StackTrace:
   at System.IO.StreamReader..ctor(Stream stream, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean leaveOpen)
   at System.IO.StreamReader..ctor(Stream stream)
   at MiniExcelLibs.Csv.CsvConfiguration.<>c.<.cctor>b__11_0(Stream stream) in D:\git\MiniExcel\src\MiniExcel\Csv\CsvConfiguration.cs:line 13
   at MiniExcelLibs.Csv.CsvReader.<Query>d__0.MoveNext() in D:\git\MiniExcel\src\MiniExcel\Csv\CsvReader.cs:line 17
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at MiniExcelLibs.Tests.MiniExcelCsvTests.Create2x2_Test() in D:\git\MiniExcel\tests\MiniExcelTests\MiniExcelCsvTests.cs:line 30


@shps951023 shps951023 moved this from In progress to Done in MiniExcel Mar 25, 2021
@shps951023 shps951023 unpinned this issue Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed todo
Projects
MiniExcel
  
Done
Development

No branches or pull requests

1 participant