Skip to Content

Make a word to move one backspace forward?

I have a rather big flat file that I need to import into a SQL server. The issue I am having is that I need to make the word "From" to move one backspace forward so that the line that starts with the word is lined up with the previous line.





If there were just a few of these, then I could do this manually, but there are a lot of these. The file is currently in text file format.

Help, please?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • May 09 at 05:01 PM

    "one backspace forward" doesn't make sense to me. From your example, I think how I would describe what you are trying to do as "remove newlines when they occur before the string 'From'. " If that interpretation isn't right, let me know.

    Some scattered thoughts on the issue:

    1) When you say "big file", it would be good to quantify the size. For some people a megabyte is big, for others a gigabyte, for still others a file might not be big until you get to terabytes.

    2) There is a difference between windows and unix on how newlines are represented. dos/windows uses a carriage return character plus a newline character while unix uses just a newline. The specifics of what you have to do will depend on how your file is formatted.

    3) For files under ~10MB, if I'm working on a PC, I often use the "find and replace" feature in Microsoft Word as a convenient solution to this sort of thing. Word has an option to show show/hide special characters such as paragraph markers. Word probably considers the newline character you want to remove a paragraph marker; in the find and replace feature this is represented as '^p' so you would want to change "^pFrom" to "From". It might, however, be a "manual line break" which would be '^l' rather than '^p'.

    4) Another approach would be to use something like the commands 'sed' or 'awk'. These are more common on unix hosts but can also be installed on windows. There are lots of examples and tutorials on how to use these available on the internet. Here is one example


    Add comment
    10|10000 characters needed characters exceeded