Search code examples
sqlexcelsqliteandroid-sqlite

I am getting double quotes error in sqlite


I am preparing my SQL query in excel after that c/p to sqlite editor. I tried two different editor and the problem is same. For example in Excel this is how my query looks

enter image description here

enter image description here

INSERT INTO jokes_table (id, title, joke, cat, fav, bookmark)
VALUES ("9", "There''s this dyslexic guy... he walked into a bra...", "There''s this dyslexic guy... he walked into a bra...", "Bar", "0", "0");

in sqlite editor it becomes

"INSERT INTO jokes_table (id, title, joke, cat, fav, bookmark) VALUES (""1"", ""What do you call a cow with no legs?

Ground Beef!"", ""What do you call a cow with no legs?

Ground Beef!"", ""Animal"", ""0"", ""0"");"

There is extra quotes starting and end of query. I know that's happens because of "bottom line" but if I remove the extra quotes manually the editor can run code without any error even if it have bottom line. There is 10.000 query and i can't remove manually. How can I fix it? Thanks a lot


Solution

  • It may not be the best way but you can save it as Formatted Text (Space delimited) and use that to copy paste later on.

    In Excel 2019

    1. Save As > More Option >
    2. In Save As Type dropdown choose Formatted Text (Space delimited)
    3. Rename your file to filename.txt (.txt & not. prn)

    Open and copy paste from there

    See below screenshot for format

    enter image description here


    One more workaround is to use Notepad++.

    1. Open csv in notepad++
    2. Press Alt and select all " in the beginning of your queries & delete.
    3. Select ;" -> Press CTRL+H -> Replace ;" with ;.
    4. Done

    See GIF below

    enter image description here