Split text to X characters *Resolved*

limer

Member
May 19, 2006
180
0
0
I'm looking for software or a plugin that will split text to 1000 characters chunks for database applications with this limit.

Anyone know of anything?

Update:

TextWedge does what I need
 
Last edited:

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,837
4,817
75
Split how? E.g. if there was a 5 character limit, would you want the word database to be:

datab ase

or

datab
ase

or just "datab"?
 

limer

Member
May 19, 2006
180
0
0
Split how? E.g. if there was a 5 character limit, would you want the word database to be:

datab ase

or

datab
ase

or just "datab"?

I would like the splitter to either go to the end of the previous line as close to one thousand characters as possible (CR?) or possibly to the last nearest full word (last whitespace).
 

limer

Member
May 19, 2006
180
0
0
you dont have *nix?

Not in my work environment, no. I currently use notepad++ to do quick checks where the cursor is. I've looked through the menus and haven't found what I'm looking for. I'll use gvim if I need to, although I'd appreciate a *nix friendly person giving me the commands to do this.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,837
4,817
75
OK, you didn't answer my question, but assuming you wanted the second option, in GVim:

1. This does what you want, but may leave blank lines after lines of exact multiples of 1000 characters:

:%s/\(.\{1000\}\)/\1\r/g

2. This does nearly what you want, doesn't leave blank lines, but the first line is only 999 characters long:

:%s/\(.\{999\}\)\([^\n]\)/\1\r\2/g
 

CuriousMike

Diamond Member
Feb 22, 2001
3,044
544
136
I'm PM'ing you a link to a small C++ project I made that I *think* does what you're asking.

The project has the executable (which you can choose to ignore ), plus the C++ source file and the MSVS 2008 Express solution.

So, if you want to modify what I made, just open it up and have at.
 

limer

Member
May 19, 2006
180
0
0
OK, you didn't answer my question, but assuming you wanted the second option, in GVim:

1. This does what you want, but may leave blank lines after lines of exact multiples of 1000 characters:

:%s/\(.\{1000\}\)/\1\r/g

2. This does nearly what you want, doesn't leave blank lines, but the first line is only 999 characters long:

:%s/\(.\{999\}\)\([^\n]\)/\1\r\2/g

I see now that my question wasn't well though out.

I believe what I mean to say is that I want to paste text that may be over 1000 characters into a web-based text field that has a 1000 character limit. This is a ticketing system and to do over 1000 characters, I have to manually find the end of a line that is less than 1000 characters. I am able to make subsequent 1000 character maximum limit logs after I have created and saved the first. It's really more about having text up to the last line with unbroken words that is less than 1000 characters.

In any event, I tried both of your commands in gVim and it came back with:

E486: Pattern not found

It may very well be something I'm doing wrong.

I'm PM'ing you a link to a small C++ project I made that I *think* does what you're asking.

The project has the executable (which you can choose to ignore ), plus the C++ source file and the MSVS 2008 Express solution.

So, if you want to modify what I made, just open it up and have at.

Thanks Mike. I tried your program and ended up copying a few paragraphs of text from:

http://www.gutenberg.org/files/11/11.txt

into a text file called alice.txt

I ran your program using:

Code:
breaktest alice.txt 1000

I end up with a file called alice.txt.new.txt that has the carriage returns and tabs stripped out. It's essentially the same file so far as I can tell.
 

CuriousMike

Diamond Member
Feb 22, 2001
3,044
544
136
limer,
I didn't understand your problem.
I've updated my program to do what I think you want.
The segments still go in a *single* file, but are delimited clearly in your defined char width.
 

limer

Member
May 19, 2006
180
0
0
limer,
I didn't understand your problem.
I've updated my program to do what I think you want.
The segments still go in a *single* file, but are delimited clearly in your defined char width.

Thanks Mike, but I believe both files are the same. I tried with both FDM (Free Download Manager) and without (firefox managed) and came up with:

Code:
MD5: fd68be5180cfb7121a464a61baa4aaa6

for both files.

I found a gui solution with TextWedge which works well for me as I can preview the would be file split chunks without opening a number of files.

If you'd like, I'd still be willing to test your programs for you. :)

Thanks again everyone!