Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Commas within CSV Data

Tags:

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?

like image 332
Sidharth Avatar asked Nov 08 '10 12:11

Sidharth


People also ask

How does CSV handle commas in data?

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.

Can CSV values have commas?

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.

How do I put a comma in a CSV file?

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'

Should CSV have comma at end of line?

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.


1 Answers

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

like image 141
Ajeet Malviya Avatar answered Oct 22 '22 16:10

Ajeet Malviya