RobertL
Newbie level 5
- Joined
- Jul 12, 2011
- Messages
- 8
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- The Netherlands
- Activity points
- 1,353
I was looking for a program that is able to split up txt-files at given lines (e.g. lines that start with WORD or lines that have less than say 11 characters). The only programs I could find where programs that could split txt files by filesize, so I wrote 'my program' in pseudocode. The only problem is: I don't know how to get it working. I would like to have it run directly by opening the file, so something like a Batch-file or Java would be OK (those languages I understand a little). Can someone help me translating it? The coding is allready done. Off course, if you know an existing free program that has the same function, that's OK too.
P.S.: My OS is Windows. source.txt can be in the same directory as this script.
Code:
%% variables:
NUMBER=1 % line number
XX=0 % new files get this number, e.g. file1.txt
while(NUMBER < length(source.txt))
if(length(line(NUMBER)) < 11)
check=1
else
if(check=1) % the previous line was short and the current line is not
XX++
check=0
(eventually there has to be created a new file sourceXX.txt with instead of XX a number. The name before XX (source in this case) has to stay the same as the original file (in this case 'source.txt'))
end
add a new line to sourceXX.txt (new line without overwriting others. XX is again a number)
end
NUMBER++ % go to next line
end
P.S.: My OS is Windows. source.txt can be in the same directory as this script.
Last edited: