Hi,
I have a csv file which i need to convert to a data table. The csv file uses " as a text qualifier.
When reading the file through LoadOptions(LoadFormat.CSV) the file is not getting parsed correctly.
PFA a sample of the csv file.
Please advise
Thanks & Regards
Hi,
Please use the following code to load the file. Please specify the separator as highlighted in red.
C#
//Instantiate Text File’s LoadOptions
TxtLoadOptions txtLoadOptions = new TxtLoadOptions();
//Specify the separator
txtLoadOptions.Separator =’"’;
//Specify the encoding type
txtLoadOptions.Encoding = System.Text.Encoding.UTF8;
//Create a Workbook object and opening the file from its path
Workbook wb = new Workbook(“e:\test\abc.txt”, txtLoadOptions);
My file is a Comma Seperated file which has values within double quotes. For e.g:
"123,456,789,abc"
I need to retrieve each of the values and put them in a datatable.
How can i specify to retrieve values which are seperated by commas only
Hi,
I have loaded your csv file and saved it in xlsx format, when I opened your original file into Ms-Excel and the output xlsx file in Ms-Excel, both look same.
When you will load the csv file into a datatable, you will get the same result as shown in Ms-Excel.
Please see the screenshot, how your file looks like in Ms-Excel.
C#
string filePath = @“F:\Shak-Data-RW\Downloads\Final.csv”;
Workbook wb = new Workbook(filePath);
wb.Save(filePath + “.out.xlsx”);