Staredit Network > Forums > Technology & Computers > Topic: Splitting a large file into smaller individual files
Splitting a large file into smaller individual files
Apr 28 2015, 5:17 am
By: rockz  

Apr 28 2015, 5:17 am rockz Post #1

ᴄʜᴇᴇsᴇ ɪᴛ!

There's a million programs out there which will take a large file and split it up in 500 MB increments, but I'd like to split up a large text file (or binary file) and search for header text.

For example, if I have a text file like this:
Code
NEWFILE:The rain in Spain falls mainly on the plain.NEWFILE:Some people just want to watch the world burn.NEWFILE:When is a door not a door?

I want 3 files to be output with the following text in them:

The rain in Spain falls mainly on the plain.
Some people just want to watch the world burn.
When is a door not a door?

There has got to be an easy way to do this that someone has already come up with.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Apr 28 2015, 5:26 am O)FaRTy1billion[MM] Post #2

👻 👾 👽 💪

This would be easy to do with probably any scripting language ... otherwise it'd be easy enough to throw together a simple C program for it.



TinyMap2 - Latest in map compression! ( 7/09/14 - New build! )
EUD Action Enabler - Lightweight EUD/EPD support! (ChaosLauncher/MPQDraft support!)
EUDDB - topic - Help out by adding your EUDs! Or Submit reference files in the References tab!
MapSketch - New image->map generator!
EUDTrig - topic - Quickly and easily convert offsets to EUDs! (extended players supported)
SC2 Map Texture Mask Importer/Exporter - Edit texture placement in an image editor!
\:farty\: This page has been viewed [img]http://farty1billion.dyndns.org/Clicky.php?img.gif[/img] times!

Apr 28 2015, 5:27 am NudeRaider Post #3

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

Well it should be pretty easy to program yourself. You just gotta know how the header looks like*. Because individual files have an EOF Marker, which can obviously not be inside the large file to separate the subfiles.

* And that's why there's probably no program that does that yet, because every file(type) has a different header, if it has one at all.
But I'm assuming you know what's inside the large file so it should be doable.




Apr 28 2015, 1:51 pm Roy Post #4

An artist's depiction of an Extended Unit Death

Yeah, it's a trivial implementation. You could go and download LinqPad and then throw a few C# statements into it:
Code
string text = File.ReadAllText(@"C:\path\to\file.txt");
string delimiter = "NEWFILE:";
string[] splits = Regex.Split(text, delimiter);
for (int i = 0; i < splits.Length; i++)
{
   if (!string.IsNullOrEmpty(splits[i]))
   {
       File.WriteAllText(@"C:\path\to\file_" + i + ".txt", splits[i]);
   }
}


But I went ahead and made a GUI for you in case you don't want to bother with all that. See attached. (Haven't tested it with non-text files, though.)

Attachments:
QuickSplit.exe
Hits: 1 Size: 10.5kb




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[2024-4-22. : 6:48 pm]
Ultraviolet -- :wob:
[2024-4-21. : 1:32 pm]
Oh_Man -- I will
[2024-4-20. : 11:29 pm]
Zoan -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
You should do my Delirus map too; it's a little cocky to say but I still think it's actually just a good game lol
[2024-4-20. : 8:20 pm]
Ultraviolet -- Goons were functioning like stalkers, I think a valk was made into a banshee, all sorts of cool shit
[2024-4-20. : 8:20 pm]
Ultraviolet -- Oh wait, no I saw something else. It was more melee style, and guys were doing warpgate shit and morphing lings into banelings (Infested terran graphics)
[2024-4-20. : 8:18 pm]
Ultraviolet -- Oh_Man
Oh_Man shouted: lol SC2 in SC1: https://youtu.be/pChWu_eRQZI
oh ya I saw that when Armo posted it on Discord, pretty crazy
[2024-4-20. : 8:09 pm]
Vrael -- thats less than half of what I thought I'd need, better figure out how to open SCMDraft on windows 11
[2024-4-20. : 8:09 pm]
Vrael -- woo baby talk about a time crunch
[2024-4-20. : 8:08 pm]
Vrael -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
so that gives me approximately 27 more years to finish tenebrous before you get to it?
[2024-4-20. : 7:56 pm]
Oh_Man -- lol SC2 in SC1: https://youtu.be/pChWu_eRQZI
Please log in to shout.


Members Online: Roy