Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
2.53/5 (3 votes)
See more:
Hi Folks,

I would to build an appplication which reads excel, writes changes to the new excel:
some requests are:
I have an Excel(.csv) which contains lot of unwanted characters like
single quotes, double quotes, comma. So I want to remove all these unawanted charaters for the excel(.csv). And update the excel(.csv) and store new excel(.csv).

I have many .csv files with unwanted characters so i want to make it automated using C# code

Can any one please help me on this.
Posted
Updated 24-Jun-14 6:38am
v2
Comments
[no name] 24-Jun-14 12:21pm    
Help you with what? You would have to have some sort of a problem first.
[no name] 24-Jun-14 13:41pm    
No. We don't write code to order here and you know that. How about YOU write some code and then if you have a specific problem, come back and ask a specific question.
apr1234 24-Jun-14 14:15pm    
Not code... i was asking for some helpful links!!
I tried but i was not able!!
[no name] 24-Jun-14 15:50pm    
Again... help with what? We can't see that you have tried anything at all. You know a CSV file is just text, right? So are you telling us that you are unable to open a text file and read text from it? This is not the do my research for me and give me links section. Please go read the FAQ for how to ask a question. Especially #2.
apr1234 2-Jul-14 14:53pm    
Hm... Really? :P

PIEBALDconsult wrote:

You can do that very easily, but then it might no longer be a CSV.


It's true.

I'd suggest you to use ADO.NET to read and write *.csv files: Accessing Microsoft Office Data from .NET Applications[^]
How To Use ADO.NET to Retrieve and Modify Records in an Excel Workbook With Visual Basic .NET[^] - i know it's VB.NET, but VB.NET is quite similar to C#.

In case you'll still want to change some values, have a look here: Range.Replace method[^]
 
Share this answer
 
v2
You may use a powerful command line tool, Microsoft Log Parser 2.2[^], to transform CSV and other files to a desired file.

Also you may try the gwebcmd[^] command line tool.

It allows you to transform different csv formats into several unified formats for futher import into databases.

For example, to change the separator, run:
gwebcmd texttocsv src.csv dest.csv /separator=;


In addition, you may combine multiple csv files into a one big file before importing to reduce import time.
 
Share this answer
 
you have to use LinqToExcel dll. download from nuget u wil be able to do all sort of operation on workbook. http://www.codeproject.com/Articles/659643/Csharp-Query-Excel-and-CSV-Files-Using-LinqToExcel
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900