I have a file that is a bunch of data all on one line.
For purposes of importing it into MS Access, I’d like to insert a NEWLINE every 180 characters.
How would I do that?
Is this a one time thing or something that reoccurs?
And how much data do you have?
For smallish files (say up to a few thousand characters or maybe tens of thousands) you could do it with a keyboard macro in something like Ultra-Edit. Just load the file, put your cursor in row 1, position 1. Now record a macro that hits the right arrow 180 times, then the enter key, then stop recording. You should now have one row of 180 characters, and the second row with all the remaining data.
Now with your cursor in row 2, column 1, Just keep hitting the macro play key (you can probably just hold it down,) until you’ve divided the whole file up into 180 character rows.
Uh, probably a monthly thing.
Will look into Ultra-Edit.
On edit:
Also, it’s just under 10 MB.
What’s the data look like? And you don’t need a new line if you can insert a uniqe charactor like a pipe ( | ).
For more permanent solutions, a quick program in any of several languages (including Access I think) should allow you to define a text file with fixed length records, then append a carriage return/line feed (hex x0D0A) or just a line feed (x0A) to each record, and write the records back out to some standard format.
I’m no access expert, but I think it allows for reading a DOS text file, fixed record length, and no record delimiters.
What, exactly, do you mean when you ask “what does it look like?”
It’s not easy to describe, exactly.
13 columns, variable-width fields, space characters used to pad the columns.
Could you open it in a text editor, set the line length to 180, copy it, and paste it in another file?
On Linux:
sed -e "s/.\{180\}/&
/g"
sorry, that doesn’t help unless you want to use a windows port of sed in a dos prompt
Here is a quickie batch file I wrote to split lines at 180 chars.
This is the type of thing where regular expressions really come in handy. My recommendation would be a combination of the suggestions made by RJKUgly and Fubaya:
[list=“1”]
[li] Download Textpad (a full-featured text editor, like UltraEdit), and use it to open the file[/li][li] In the Search menu, navigate to Search –> Replace (the shortcut key is F8)[/li][li] In the Find/Replace dialog, enter the following values:[/li][list=“1”]
[li] Find: .{180}[/li][li] Replace: &[/li]
[li] Check the “Regular expression” checkbox[/li][/list]
[li] Click the “Replace All” button[/li][/list]
This Find/Replace will literally insert a newline character after every 180 characters.
I used
in my example but isn’t windows newline different? \r or something?
Windows uses carriage return and newline together: