|
Breaking 1 large into many small files
|
|
02-02-2010, 05:37 PM
Post: #1
|
|||
|
|||
|
Breaking 1 large into many small files
I am trying to write a program to break apart one large file into many files.
Specifically I am needing to write an individual file from each section in the file that starts with the > symbol and then name the file with the following 8 characters. I am having trouble getting the program to name the files and then append the data up till the next > symbol into the individual file. Thank you. Warm Regards, Website Design India Submit Free Links Website Design Faridabad |
|||
|
02-02-2010, 05:53 PM
Post: #2
|
|||
|
|||
|
RE: Breaking 1 large into many small files
show the code first , i mean what u've tried aand we will help
|
|||
|
02-03-2010, 07:13 PM
Post: #3
|
|||
|
|||
|
RE: Breaking 1 large into many small files
This isn't much but i havent been able to make it too successful yet so ive outlined the basic gist of it. I was trying to do the same thing in matlab but couldnt get it to work and now im trying perl.
#!/usr/bin/perl use warnings; use script; open SS, ('ss.txt'); while ( <SS> ) { #identify '>' #write new file and name it with the next eight characters #put the data between the first > and the next > in that file #put file into secseq thats the file that would contain all the individual files #close file #end #then start with next next part and repeat till the end of the file. Warm Regards, Website Design India Submit Free Links Website Design Faridabad |
|||
|
02-04-2010, 07:46 PM
Post: #4
|
|||
|
|||
|
RE: Breaking 1 large into many small files
Set the input record separator i.e., $/ to ">" or "\n>" and read-in the file in chunks.
Use substr to extract the 8 characters to be used for the filename. Open the new file in write mode, ouput the chunk of data and close the file. |
|||
|
« Next Oldest | Next Newest »
|





