I have a CSV file which I am directly importing to a SQL server table. In the CSV file each column is separated by a comma. But my problem is that I have a column "address", and the data in this column contains commas. So what is happening is that some of the data of the address column is going to the other columns will importing to SQL server.
What should I do?
Re: Handling 'comma' in the data while writing to a CSV. So for data fields that contain a comma, you should just be able to wrap them in a double quote. Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes.
A comma-separated values (CSV) file is a delimited text file that uses a comma to separate values. Each line of the file is a data record. Each record consists of one or more fields, separated by commas. The use of the comma as a field separator is the source of the name for this file format.
In Excel, click Data > Get External Data > Import Text File… Browse to select your CSV file and click 'Get Data' Choose “Delimited” as the file type and click 'Next' Check the “Comma” box as the delimiter and click 'Next'
The rules for data which it understands are as follows: Each row must have the same number of comma-separated fields. Whitespace (space or tab) adjacent to a comma is ignored. Adjacent commas, or a comma at the start or end of a line (whitespace apart) indicates a null field.
For this problem the solution is very simple. first select => flat file source => browse your file => then go to the "Text qualifier" by default its none write here double quote like (") and follow the instruction of wizard.
Steps are - first select => flat file source => browse your file => Text qualifier (write only ") and follow the instruction of wizard.
Good Luck
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With