 |
|
 |
I am looking for a splitting software whcih could split a file at a specific "target"
For example, in the file you find
"title 1"
......
"title2"
.....
"title n"
I want to cut before each "title n" and get n files at the end
best regards
|
|
|
|
 |
|
 |
We can take this offline. email me @ pclaassens@starbal.net
|
|
|
|
 |
|
 |
Hello All,
I need expertise from you ppl on the following requirement:
File Size: 30 GB (that needs to be splitted).
Record Size in the file: 70 bytes
I need to split the above file based on following 2 conditions:
1) Number of records in the new file - 1 million
2) The first field in the record (named id) shouldnt change.
For eg:
1122334455|ABCD|1111111111|2222222222|3333333333|4444444444|AB|01|M01
1122334455|ABCD|1111111111|2222222222|3333333333|4444444444|AB|01|M01
1122334455|ABCD|1111111111|2222222222|3333333333|4444444444|AB|01|M01
1122334455|ABCD|1111111111|2222222222|3333333333|4444444444|AB|01|M01
1122334455|ABCD|1111111111|2222222222|3333333333|4444444444|AB|01|M01
1122334455|ABCD|1111111111|2222222222|3333333333|4444444444|AB|01|M01
suppose if the file limit is reached to 1 million, i want to check the first field of the current record and the next record (and this will go in loop until the id changes), and if it matches, it should go in the current file (in this case, it exceeds 1 million records...but thats ok for me)...I dont want to have the same id in 2 different files.......
I want to do this code in C++.
Kindly help ASAP.
Regards,
Jayesh
|
|
|
|
 |
|
 |
Now i have lots of txt files ,some of them are chinese file,and some of them are english ,now i want combination them into one text file.and the order is given.e,g;oneenglish.txt,twoenglish.txt,one chinese.txt.two chinese.txt.what i want to do is that make one-to-one ,the chinese file is after the english file, how can i make them together use a fast way?
Thx advance!
初学者!Don't try it, just do it!
*Archibald*rever dragon!
|
|
|
|
 |
|
 |
hi, your program crashs, if you don't know exact nr of lines // initialise currentLine to 0 (i.e. the first line of input file long currentLine = 0; //add new long numLinesLastFile = TotalLines - ((numFiles-1)*numLinesForEachFile); //end of new // create 'numFiles' amount of output files.... for (long i = 1; i <= numFiles; i++) { ... //add new if(i == numFiles) numLinesForEachFile = currentLine + numLinesLastFile; //end of new .. for (int j = currentLine; j < numLinesForEachFile; j++) { fout << line[j] << endl;}
dan
|
|
|
|
 |
|
 |
Small question friend,
why do you have a line limit? Why do you "store" the file? Why do you use "vectors" or "arrays"?
Surely, you take the input, line per line, if that's what you want, and then store it, line by line, when a new file is needed, you create one?
getoutputfilename
openfile source { conio or whatever }
openfile dest
while file_left_to_do
.strline = readline from source
.linecounter = linecounter + 1
.if ( linecounter % linesperfile )
..fileclose
..getoutputfilename
..fileopen
.end if
wend
Um, no file "length" issues?
Interesting choice.
Peace.
Dunk
nacnud_uk27SPAM_SPAM_MAPS_MAPS@SPyahoo.coSPAMm
|
|
|
|
 |
|
 |
Hi there,
Thanks for the question... I must admit you have a valid point there - Here is a brief explanation on the choices:
1. Why do you have a line limit? Well, the array I used in the beginning was just hardcoded to a 1000 as I never expected someone to use text-files with millions of lines. The choice for vector was the easiest at the time with the least amount of code change.
2. Why do you "store" the file? Not sure what you mean…
3. Why do you use "vectors" or "arrays"? 2 reasons: I needed practice on classes & vectors for my practical c++ exam. I recon it would be the perfect project to experiment with.
The final reason is because I needed to count how many files there exist in the source file before my output_files loop can start. So I created the private class method to count the lines. Again, vectors seemed like the easiest choice and because I have to iterate through the source file once anyway, so I just pushed each line into the vector. (This could be retrieved on the CreateOutputFiles method later)
Your pseudocode does make sense to me and will probably work – guess it’s just a different style of programming and the way I designed the class @ the time.
Cheers,
Pieter
|
|
|
|
 |
|
 |
Pieter,
More below.
>Hi there,
>
>Thanks for the question... I must admit you have a valid point there - Here is a brief >explanation on the choices:
Thank you.
>
>1. Why do you have a line limit? Well, the array I used in the beginning was just >hardcoded to a 1000 as I never expected someone to use text-files with millions of >lines. The choice for vector was the easiest at the time with the least amount of >code change.
>
Ah, one of the programmers first lessons friend, *never*, and I mean *never*, assume anything. The rule is, if it can happen, it *will* happen. Just a bit of a hint.
>2. Why do you "store" the file? Not sure what you mean…
It’s a hint to my proposed implementation. You need not store the file, in any sort of array, as you are doing, you can just use the implementation that I had suggested, then the only thing you have to store, at the very most, is one line at a time. You could get away with character per character, and cut it down to just 8 bits, but that’s a bit dramatic, and slow. If speed were to become an issue on huge files, you could read 2K blocks or so, at a time, work in memory, and then read another 2K block.
>
>3. Why do you use "vectors" or "arrays"? 2 reasons: I needed practice on classes & >vectors for my practical c++ exam. I recon it would be the perfect project to >experiment with.
The implementation could have still been done with a class, as you could have wrapped standard functions into class methods. You could have used a base class and expanded upon it.
>
>The final reason is because I needed to count how many files there exist in the >source file before my output_files loop can start.
Why do you need to know how many lines there are, before you start? I mean, if you wanted to make sure that the “split” files were all the same size, you could do a one pass scan of the file, count the lines, and store their offset, as indexes into the file, then just write a routine that would put the same number of lines in “each file”, or your output.
>So I created the private class
>method to count the lines.
Lines could have been counted, either as you went along, or as I said, in a pre-split pass.
>Again, vectors seemed like the easiest choice and
>because I have to iterate through the source file once anyway, so I just pushed each >line into the vector. (This could be retrieved on the CreateOutputFiles method later)
Of course, I’m not criticising your implementation here friend, I’m only showing you that there were and are other ways to get to the same end and that as you become more aware of not only your own talents as a programmer, and also you increase your experience, these things will come naturally to you.
>
>Your pseudocode does make sense to me and will probably work – guess it’s just a >different style of programming and the way I designed the class @ the time.
Of course. I was just highlighting what some may see as a “limitation” of your design. And of course, you, in hindsight, can see that too. Life is for learning, and living, seems that you’ve got the basis there mate, keep at it.
>
>Cheers,
No bother, it was my pleasure, thanks for listening.
Peace,
Dunk
>Pieter
>
|
|
|
|
 |
|
 |
The vector line in the .h file causes several errors in VC++ 6.0
It seems correct, does anyone have any idea what the problem might be?
Peace,
Tom
|
|
|
|
 |
|
 |
Greetings,
can you tell me what kinda errors u get ? I've tested this on VC++ 6 & .NET 2002/3 and it works fine..
|
|
|
|
 |
|
 |
Hello, the link to
Download source files - 2 Kb
isn't working yet.
Greetings,
Andreas.
|
|
|
|
 |
|
 |
Hi Andreas,
The hyperlink has been fixed!
|
|
|
|
 |
|