Excel adds extra quotation marks to CSV export

I recently created an application that adds items to a database using CSV. After adding the elements, I realized that many of my values ​​had extra quotation marks (") that were not needed, and this ruined my order.

The problem is that when exporting to CSV from Excel, Excel adds extra quotation marks to all my values ​​that already contain a quote in them. I showed the difference below:

Original article: Drilling electric reversing 1/2 "6.3A

Exported item: "Electric reversible drill 1/2" "6.3"

Note: CSV export adds three (3) extra quotation marks ("). Two at the ends and one after the original intended quote.

Is there a parameter that I can change, or a formatting property that I can set in the Excel file / column? Or do I need to live with it and remove these quotes in my source code before adding them to the database?

+3
source share
6 answers

This is completely normal. External quotes are added because it is a string. The inner quote doubles to avoid it. The same thing that you saw in the SQL query, for example. Use the TextFieldParser class to be able to try and verify the correct code structure to parse this automatically for you.

+7
source

This standard.

Values ​​in the CSV file must contain quotation marks (otherwise, commas and lines in the field may be misinterpreted).

- , .

CSV:

CSV - , /, , /, . , (, ), . , , , , . CSV , .

( )

+3

Excel . .

0

. . . . , Excel .

0

, - HTML. javascript, , , # , :

base = base.replace(/""/gi, '"');
base = base.replace(/'/gi, ''');

, CSV.

0

Unicode "DOUBLE PRIME"

http://www.fileformat.info/info/unicode/char/2033/index.htm

Excel. Excel UTF-8 UTF-16.csv, schema.ini CharacterSet. , , .csv , Unicode.

Depending on the DBMS, you can use a more direct way to transfer data (SELECT / INSERT ... INTO ... IN), thereby completely eliminating CSV.

-1
source

Source: https://habr.com/ru/post/1796405/


All Articles