Extracting Data from a File


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Extracting Data from a File
# 1  
Old 07-31-2007
Extracting Data from a File

Hi

I need to calculate the number of occurrences of a item in a number of files using Perl.
The item appears continually throughout the files but in each case I only want to calculate it in certain blocks of the file.
Example - Calculalte the number of occurrences of a 'pass' in a block of code which starts with 'Start' and end with 'Finish'.
It is not possible to say start at line 1 and count the number of occurrences of the item until you reach line 5 as the files are all different sizes and the block is located at different places in all the files.

I'm sure this is possible but I just can't seem to get my head around this Perl scripting

Any help would be great
OOP
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need Help in extracting data from XML File

Hi All My input file is an XML and it has some tags and data rows at end. Starting of data rows is <rs:data> and ending of data rows is </rs:data>. Within sample data rows (2 rows) shown below, I want to extract data value after equal to sign (until space or "/" sign). So if XML data... (7 Replies)
Discussion started by: vx04
7 Replies

2. Shell Programming and Scripting

Extracting data blocks from file

Hi all, I want to extract blocks of data from a file depending on the contents of that block. The input file(table) has several blocks each starting with 'gene' in the first column. I want to extract only those blocks which do not have the expression '_T02' in the second column. Input file ... (3 Replies)
Discussion started by: newbie83
3 Replies

3. UNIX for Dummies Questions & Answers

Extracting data from file

I am trying to compare the data in lines 3 & 5 to see if they match up to the '-S570' (see first code set, all proprietary information has been removed from code set) spawn telnet Trying ... Connected to CA-LOS1234-ASE-S570.cl . Escape character is '^]'. CA-LOS1234-ASE-S570 Username: ... (1 Reply)
Discussion started by: slipshft
1 Replies

4. UNIX for Dummies Questions & Answers

Efficient way of extracting data from file

I am having a file, around 500 lines. which contains one letter words, two letters words,...and so on(up to 15 letter words and words are not seprated by line). I need to compare all 1 letter words with 3,4,5 and 6 letters word, all 2 letters words with 2,3,4 and 5 letters words and all 3 letters... (3 Replies)
Discussion started by: akhay_ms
3 Replies

5. Shell Programming and Scripting

Extracting specific lines of data from a file and related lines of data based on a grep value range?

Hi, I have one file, say file 1, that has data like below where 19900107 is the date, 19900107 12 144 129 0.7380047 19900108 12 168 129 0.3149017 19900109 12 192 129 3.2766666E-02 ... (3 Replies)
Discussion started by: Wynner
3 Replies

6. UNIX for Dummies Questions & Answers

Extracting data from an xml file

Hello, Please can someone assist. I have the following xml file: <?xml version="1.0" encoding="utf-8" ?> - <PUTTRIGGER xmlns:xsd="http://www.test.org/2001/XMLSchema" xmlns:xsi="http://www.test.org/2001/XMLSchema-instance" APPLICATIONNUMBER="0501160" ACCOUNTNAME="Mrs S Test"... (15 Replies)
Discussion started by: Dolph
15 Replies

7. Programming

Help in extracting data with command from file in C

Hi, I have a file which stores the following array :- 1,2,3,4,5.........16,17,18,19,20 This file has few hundreds of inputs of these lines. I would like to read this file one line at a time; and assign to an array which is separated by ",". I tried to do fgets command however,... (10 Replies)
Discussion started by: ahjiefreak
10 Replies

8. Shell Programming and Scripting

Extracting Data from xml file

Hi ppl out there... Can anyone help me with the shell script to extract data from an xml file. My xml file looks like : - <servlet> <servlet-name>FrontServlet</servlet-name> <display-name>FrontServlet</display-name> ... (3 Replies)
Discussion started by: nishana
3 Replies

9. UNIX for Advanced & Expert Users

Extracting data from an AFP file

Hello Anybody any idea how to extract data from an AFP file using UNIX commands? I could make the AFP to PDF or if there is any other to change it to to make the extraction simplar. I'm open to ideas. Cheers (4 Replies)
Discussion started by: Dolph
4 Replies

10. UNIX for Dummies Questions & Answers

extracting recursive data file

Hi Gurus, Can awk be able to do this source file: 1|SPFE2027G1|1PFE-7000|T34801188|5066-0844| 2|T34801188|5066-0844|T35002355|5066-0845| 3|T35002355|5066-0845|T35203409|QFBR-7798| 1|SPFE2027H1|1PFE-7000|T34801198|5066-0844| 2|T34801198|5066-0844|T35002365|5066-0845| formatted into:... (1 Reply)
Discussion started by: bbeugie
1 Replies
Login or Register to Ask a Question
Algorithm::Dependency::Source::File(3pm)		User Contributed Perl Documentation		  Algorithm::Dependency::Source::File(3pm)

NAME
Algorithm::Dependency::Source::File - File source for dependency heirachys DESCRIPTION
Algorithm::Dependency::Source::File implements a source where the items are stored in a flat file or a relatively simple format. File Format The file should be an ordinary text file, consisting of a series of lines, with each line completely containing the information for a single item. Blank lines, or lines beginning with the hash character '#' will be ignored as comments. For a single item line, only word characters will be used. A 'word character' consists of all letters and numbers, and the underscore '_' character. Anything that is not a word character will be assumed to be a seperator. The first word will be used as the name or id of the item, and any further words in the line will be used as other items that this one depends on. For example, all of the following are legal. # A single item with no dependencies Foo # Another item that depends on the first one Bar Foo # Depending on multiple others Bin Foo Bar # We can use different seperators One:Two|Three-Four+Five=Six Seven # We can also use multiple non-word characters as seperators This&*&^*&File: is& & & :::REALLY()Neat From the examples above, it should be easy to create your own files. METHODS
This documents the methods differing from the ordinary Algorithm::Dependency::Source methods. new $filename When constructing a new Algorithm::Dependency::Source::File object, an argument should be provided of the name of the file to use. The constructor will check that the file exists, and is readable, returning "undef" otherwise. SUPPORT
To file a bug against this module, use the CPAN bug tracking system http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Algorithm-Dependency <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Algorithm-Dependency> For other comments, contact the author. AUTHOR
Adam Kennedy <adamk@cpan.org> SEE ALSO
Algorithm::Dependency COPYRIGHT
Copyright 2003 - 2009 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.12.4 2009-04-14 Algorithm::Dependency::Source::File(3pm)