Timeline for Exporting/Importing data from SQL Server 2014 to PostgreSQL 9.5 with tab delimited files
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 7, 2020 at 4:42 | comment | added | Chris Hughes | COPY foo FROM 'asdf.csv' WITH (FORMAT CSV, DELIMITER E'\t'); would this not be COPY foo FROM 'asdf.txt' WITH (FORMAT txt, DELIMITER E'\t'); | |
Nov 28, 2017 at 19:18 | comment | added | Dina | I'm exporting from SQL Server using BCP (Windows). Importing into PostgreSQL. No issue with tabs in data (YET). I have the file but it is too sensitive to share here.... I may just have to find a workaround for now. Remove the offending data (quotes & commas) and use CSV. I did want to understand this though!! Maybe need to come back to it with a fresh mind. | |
Nov 28, 2017 at 19:07 | comment | added | Evan Carroll |
When you export a file with PostgreSQL the delimiter is escaped with the ESCAPE character. So it doesn't matter. If your deliminter is a E'\t' and it occurs in the table it'll simply be escaped with ``. Do you have the file you're trying to import?
|
|
Nov 28, 2017 at 19:05 | comment | added | Evan Carroll |
Tabs are just a character. That character is usually displayed as (\t , or two, four or eight spaces). With vim, the editor I use, you can set it yourself set ts=4 , set ts=8 , but you're only changing the rendering of that character.
|
|
Nov 28, 2017 at 19:02 | comment | added | Dina | I mean it is in the data I am trying to export, so putting double quotes around it won't work. Have you heard anything about windows tab being 4 spaces and linux tab being 8 spaces? Or is this crazy talk in the depths of googling... I will try a test file next. | |
Nov 28, 2017 at 18:52 | comment | added | Evan Carroll | When you say "text of my table itself" what are you referring to? Try to create a test-case for it. | |
Nov 28, 2017 at 18:51 | comment | added | Evan Carroll | The tab is is dependent on the encoding of the system, but it's the same being part of the ascii characters. | |
Nov 28, 2017 at 18:45 | comment | added | Dina | You're right, WITH (FORMAT CSV) can totally handle double quotes. I found out that my issue was actually double quotes and commas in the text of my table itself. Hence my need to use tab as delimiter. I think at this point I am guessing windows tab is not the same character as linux tab. Still checking!! (Not sure if I should update my question since you have quoted me!) | |
Nov 24, 2017 at 23:19 | history | answered | Evan Carroll | CC BY-SA 3.0 |