CSV to Tab Delimiter file
-
I am developing a system using ASP.NET with VB script. I have a function to import CSV file into my SQL server database. As i found out the comma will effect my data placement in my tables, so i think of to develop a function to convert the CSV file to Tab Delimiter file. Is it possible to develop the function? As i found out, there are many converter outside that need to buy for the converter, it is not convenient for me to buy it. Please give me any suggestion or solution, thank you.
-
I am developing a system using ASP.NET with VB script. I have a function to import CSV file into my SQL server database. As i found out the comma will effect my data placement in my tables, so i think of to develop a function to convert the CSV file to Tab Delimiter file. Is it possible to develop the function? As i found out, there are many converter outside that need to buy for the converter, it is not convenient for me to buy it. Please give me any suggestion or solution, thank you.
Well, your problem here is that your import data is ambiguous. You don't know whether a comma represents a field separator or a digit grouping symbol. The best thing to do is to change the import data format, for example to put quotes around numeric fields that can have a digit grouping symbol in them, or indeed to put quote marks around all fields. It's then traditional to double quote marks that actually appear within a field. Bulk insert is typically easiest to handle with fixed field widths rather than the use of separators. There's what looks to be a good CSV file reader class at http://www.codeproject.com/cs/database/CsvReader.asp[^] (disclaimer: I haven't used it). You could use this to write a convertor to tab-separated format once you've sorted out the ambiguity, if you can't get the source data generated in a usable format.
Stability. What an interesting concept. -- Chris Maunder