Guest_imported
New member
- Jan 1, 1970
- 0
Hi all,
The idea is to split up a file containing, let's say, 17 words (one on each line), into smaller files, each containing 3 words (only the last file is allowed to have less). Example:
testfile.txt:
"aabb
"bbcc
"ccdd
"ddee
"eeff
"ffgg
"gghh
"hhii
"iijj
"jjkk
"kkll
"llmm
"mmnn
"nnoo
"oopp
"ppqq
"qqrr
This file should be split up into:
testfile_1:
"aabb "bbcc "ccdd
testfile_2:
"ccdd "ddee "eeff
testfile_3:
"eeff "ffgg "gghh
testfile_4:
"gghh "hhii "iijj
etc.
Remarks:
- each new file should start with the name of the original
file (leaving out the extension, though), followed by an
underscore and its number (as you can see in the example);
- the second outputfile should start with the last word of
the first outputfile, the third outputfile should start
with the last word of the second outputfile, etc.
- in the outputfiles, words should be placed after one
another, with only one white space between them and a
newline after the last word.
(optional:
- it would be nice if the size of the outputfiles (in this
case three words) could be changed on the comand line;
and if more than one large file could be placed on the
command line.)
Can someone help me with this? I would be very grateful Thanks,
kredit99
The idea is to split up a file containing, let's say, 17 words (one on each line), into smaller files, each containing 3 words (only the last file is allowed to have less). Example:
testfile.txt:
"aabb
"bbcc
"ccdd
"ddee
"eeff
"ffgg
"gghh
"hhii
"iijj
"jjkk
"kkll
"llmm
"mmnn
"nnoo
"oopp
"ppqq
"qqrr
This file should be split up into:
testfile_1:
"aabb "bbcc "ccdd
testfile_2:
"ccdd "ddee "eeff
testfile_3:
"eeff "ffgg "gghh
testfile_4:
"gghh "hhii "iijj
etc.
Remarks:
- each new file should start with the name of the original
file (leaving out the extension, though), followed by an
underscore and its number (as you can see in the example);
- the second outputfile should start with the last word of
the first outputfile, the third outputfile should start
with the last word of the second outputfile, etc.
- in the outputfiles, words should be placed after one
another, with only one white space between them and a
newline after the last word.
(optional:
- it would be nice if the size of the outputfiles (in this
case three words) could be changed on the comand line;
and if more than one large file could be placed on the
command line.)
Can someone help me with this? I would be very grateful Thanks,
kredit99