How to copy a .out file to postgresql?

copy java out postgresql sqlbulkcopy

Question

I have this file (warning: potentially unsafe file download site) that I need to insert into the database using Postgres and Java. Please download it and let me know how I can extract data from this file. I tried the copy command. For one, it did not let me use the header option. I have to, as you can see from the file, copy data from the 4th row onwards. Another thing is the delimiter. If you read the file in notepad++, you can see them as proper columns, but there is no delimiter as such. I have tried and faced these challenges. Please help me get a custom query. Or another approach that can achieve what I want to do. Thanks!

Edit: I have used a safer link to download the file. Hope it works.

1
-2
10/13/2012 2:41:35 PM

Accepted Answer

So it sounds like you are doing fixed width files. COPY doesn't handle these so your best bet is to load up a spreadsheet, import the file (most can handle fixed width), and then export as csv. You can then use COPY.

2
10/13/2012 12:27:19 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow