473,414 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

file seperation

ok i am trying to seperate a single large .doc file into smaller individual .doc files the first script worked as the files had a common start and end line ....ie ABC....DEF... so seperation was prety easy. the second file has common start lines but not end lines is there a way i can have it look at the top line and referance the bage break befor it for the end line here is what i have so far
Expand|Select|Wrap|Line Numbers
  1. open (IN, 'te26085807.doc'); 
  2. open (OUT,'>>te_1');
  3. $outcount = 1;
  4.  
  5. while (<IN>)
  6.  
  7.  
  8.     print OUT;
  9.  
  10.        if ( $_=~/Certification of Duty for/ )
  11.         {
  12.  
  13.  
  14.             $UIC = substr $_, 42, 5;     # extract the UIC for file name
  15.  
  16.         }
  17.  
  18.         if ( $_=~/Top line of next document/ )
  19.         {
  20.  
  21.             close (OUT,'>>te_$outcount');
  22.  
  23.             rename ("te_$outcount","/xxxx/xxxxx/xxx/xxxxx/NAME$UIC.doc");
  24.  
  25.             $outcount++;
  26.  
  27.             open (OUT,">>te_$outcount");
  28.         }
  29.         }
  30.  
Nov 26 '08 #1
2 1379
ahgan
13
Try reading the beginning of file first before opening filehandler and print the line out. You can use/set a flag to determine if a filehandler is open. While reading the file content, whenever the line matches the beginning of file, check if the output filehandler is open.
1) If yes, close it, rename the file as you wish, increase your output file count... etc, open a new file for printing. (this will take care of the 2nd output file onwards)
2) If no, open a new file for printing. (this will take care of the 1st output file)
This way, you do not really need to worry about the pattern matching for the end of file.
Nov 28 '08 #2
where can i find some sample scripts on this
Nov 28 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: sea | last post by:
I have text files in the following format: 123,34, ,345,890, 123,23 .. .. .. As you can see, the problem is that (1) the commas can occur in
2
by: Richard | last post by:
When using display:block in a list array, is there a way to give a bit of seperation between the actual displays? ul {display:block;} ul li {display:block;} <ul> <li>item 1</> <li>item...
12
by: dough | last post by:
I want to read in lines from a file and then seperate the words so i can do a process on each of the words. Say the text file "readme.txt" contains the following: In the face of criticism from...
1
by: jm | last post by:
Those of you who use Visual Studio, do you find a big performance difference between the single file model and the web form / class behind form model? I am trying to justify purchasing Visual...
4
by: Mike | last post by:
Dear people , I have a question about seperating data code from presentation code for, like in client server applications. The example i am looking for goes about the topic data layer. In my...
2
by: Brett | last post by:
Does any one have examples of how to upload a file via POST and also include other form fields? Say two input boxes and a file type input. I've tried: WebRequest.Create() and...
0
by: Brett Romero | last post by:
I'm using VS 2K5. I break my forms into three files plus the RESX. I usually have: frmForm1.cs frmForm1.Designer.cs frmForm1.Logic.cs ForForm1.resx This allows me to double click the first...
2
by: empiresolutions | last post by:
Hello all. I have been working on a Website/CMS (Engine) for a few years now. With every site i build, i just copy the current version of the Engine, make some minor changes and skin it to fit the...
1
by: fturton | last post by:
hi, I have had no programming experience and would like to know how to take a text file of integers seperated by a space into an excel format. each space seperation would denote a new cell. this...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.