Unexpected Eof Encountered in Bcp

Unexpected EOF encountered in BCP

If the file is tab-delimited then the command line flag for the column separator should be -t\t -t,

Sybase bcp: Unexpected EOF encountered in BCP data-file

Since your file is only one column, remove the format file and use the -c option instead. This will BCP the file in character (plaintext) mode, and should resolve the issue.

As noted, you may need to change the EOL character to CRLF

bcp throwing unexpected EOF error unless the file has an extra \n

As @TT noted, you have sussed the problem.
One fix could be to use PowerShell to ensure there is a closing CR/LF on the file:

powershell "Get-Content -Path .\original.tsv | Set-Content -Path .\corrected.tsv;"

If there is one, it will still be there and no new one will be added.
If it is missing, it will be added.

Then modify your BCP line to use the corrected filename for the input, and clean up after yourself as normal.

BCP Fixed Width Import - Unexpected EOF encountered in BCP data-file?

So I found the offending characters in my fixed width file. Somehow whoever pulled the data originally (I don't have access to the source), escaped (or did not escape correctly) the double quotes in some of the text, resulting in some injection of extra spaces breaking the fixed width guidelines we were supposed to be following. After correcting the double quotes by hex editing the file, BCP was able to process all records using the format file without issue. I had used the -F and -L flags to examine certain rows of the data and to narrow it down to where I could visually compare the rows that were ok and the rows where the problems started to arise, which led me to discover the double quotes issue. Hope his helps for somebody else if they have an issue similar to this!

BCP unexpected EOF

The way I solve that kind of errors every day:

1) Create a table with single column tblRawBulk(RawRow varchar(1000)).

2) Insert all of the rows there.

3) Remove unnecessary unformatted rows (e.g. 'test' in your example) with WHERE-parameter. Or even remove all unnecessary rows (except of rows, that you need to load) to simplify point 5.

4) Upload this table with BCP to some workfolder.

5) Download this new file.

It's no exact what you want, but may help if you'll write corresponding stored procedure, that can automatically do all this things.



Related Topics



Leave a reply



Submit