Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Missing row delimeter {CR}{LF} in .txt file

Author  Topic 

rohaandba
Starting Member

33 Posts

Posted - 2011-02-28 : 10:09:55
I have a .txt file, I am suppose to put the data in the .txt file into a table in a database.

I generally deal such type of task using Import Export Wizard (or) SSIS.

But in this perticular .txt file there is no row delimeter "{CR}{LF}".

Can any one suggest me the ways to put the row delimeter "{CR}{LF}" after every 40 charecters (As per the Spects) in that .txt file.

So that I can load the data into the Data Base Table.

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-02-28 : 11:02:50
Usually it is not that there is no row terminator, but that the row terminator is not a {CR}{LF}. Sometimes you see only a {CR}, sometimes there may be only a {LF}. Most of the time this happens when the file was generated on a non-windows computer.

You can see what the row terminator is by opening the file in binary mode using a text editor such as TextPad. If you do have a row terminator of some sort, SSIS and Import Export Wizard allows you to specify the row terminator.

Assuming you have no row terminator at all, you would need to reformat the files to insert the row terminator. Perhaps the easiest is to use a perl script or a power shell script. I don't know a lot about power shell scripts; If you have Perl, the following script would insert a new line character after every 40 characters:
perl -pi.bak -e "s/(.{40}?)/$1\n/g;" YourInputFile.txt
Perl installations are available free - google for Active Perl.
Go to Top of Page
   

- Advertisement -