I'm trying to load some data into netezza but it won't let me as my file has linefeeds at the end of each line
my questions are: I can see the linefeeds if I look in notepad++, how do i do the equivalent in unix?
How can I change the linefeeds to add an escape character to the beggining of each linefeed so I can load into netezza?
Linefeeds are the expected character at the end of the line for nzload. I think it's carriage returns you must be having problems with.
To your first question, you can use "vi -b " to prevent vi from detecting that the file came from DOS and trying to hide the carriage returns that are causing you heartache. If you see "[dos]" at the bottom of the vi screen next to the filename, then you know there are carriage return characters there that you aren't seeing.
If your data file is to big to open in vi you can use "od -a filename" to inspect the data for carriage returns or other control characters.
If you want to retain the carriage returns in your data, whether at the end of the lines or not you can escape them with a regex like so:
Then you can use nzload with the -escapechar option to load the data. However, if you use the -escapechar option, you have to account for the possibility of having that escapechar () in your data. A more thorough prep would be like so:
You can then use nzload and verify the results.
Or, you can could just simply eradicate the carriage returns with dos2unix if they aren't actually part of the data you want, and are simply an unwanted artifact of the process that created your file, and be done with it.