Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Splitting up a file

Reply
Thread Tools

Splitting up a file

 
 
Stuart Clarke
Guest
Posts: n/a
 
      03-04-2010
Hey,

I have a quick question about breaking up a file into smaller files.

I have a large file, quite like an mbox file in how it stores its data
for example

DATA
stuff
stuff

DATA
stuff

DATA
stuff
stuff

I don't want this information in one file, I want to break it up into
single files, so the example above would give me three files. How would
you suggest I go about this?

Any help is greatly appreciated.

Thanks
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Jesús Gabriel y Galán
Guest
Posts: n/a
 
      03-04-2010
On Thu, Mar 4, 2010 at 11:21 AM, Stuart Clarke
<(E-Mail Removed)> wrote:
> I have a quick question about breaking up a file into smaller files.
>
> I have a large file, quite like an mbox file in how it stores its data
> for example
>
> DATA
> stuff
> stuff
>
> DATA
> stuff
>
> DATA
> stuff
> stuff
>
> I don't want this information in one file, I want to break it up into
> single files, so the example above would give me three files. How would
> you suggest I go about this?


If you are on linux, you can use csplit:

csplit testsplit.txt /DATA/ "{*}"

(this will generate files named xx00, xx01, etc).

Jesus.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Splitting a multirecord per file format to a single record per file format: Right approach? Randy Kramer Ruby 2 01-12-2007 06:46 PM
File-splitting Function: Uses FILE * - better way with ifstream? Earl Purple C++ 3 01-13-2006 11:29 AM
Re: Splitting up the definitions of a class into different files (splitting public from private)? John Dibling C++ 0 07-19-2003 04:41 PM
Re: Splitting up the definitions of a class into different files (splitting public from private)? Mark C++ 0 07-19-2003 04:24 PM
Re: Splitting up the definitions of a class into different files (splitting public from private)? John Ericson C++ 0 07-19-2003 04:03 PM



Advertisments