Sponsored Content
Top Forums Shell Programming and Scripting Converting text files to xls through awk script for specific data format Post 302883007 by Akshay Hegde on Friday 10th of January 2014 11:25:13 AM
Old 01-10-2014
Assuming you want to extract numeric value from line with a pattern Query and Score..

Code:
awk '
function parse(){
                   gsub(/[[:alpha:]]|[-,=]/,x)
                   $0=$0;$1=$1
                   q = q ? q OFS $0 : $0
                } 
           NR==1{
                 print "Serial", "Query start", "Query End", "target start", "target end", "Score", "E", "P", "GC"
                }      
            /^>/{
                   s=$0
                   next
                }
/Query/||/Score/{
                   parse()
                if(++i==2){
                                print s,q
                                q=s=i=""
                          }          
                }
    ' OFS="\t" file

Code:
Serial    Query start    Query End    target start    target end    Score    E    P    GC
>gi|1234|ref|    1    65    1677    1733    8.38    0.6529    0.0001513    46
>gi|54367|ref|    1    65    6780    6812    8.13    0.7692    0.0001782    36

This User Gave Thanks to Akshay Hegde For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

converting a tabular format data to comma seperated data in KSH

Hi, Could anyone help me in changing a tabular format output to comma seperated file pls in K-sh. Its very urgent. E.g : username empid ------------------------ sri 123 to username,empid sri,123 Thanks, Hema:confused: (2 Replies)
Discussion started by: Hemamalini
2 Replies

2. UNIX for Dummies Questions & Answers

converting xls,xlsx files ??

I think I know the answer to this :rolleyes: but thought I'd ask anyway. You never know. Does anyone know of a program or utility that will run on any unix platform and convert Microsoft Excel files to ascii/plain text files that unix can understand ? Thanks in advance. Floyd (3 Replies)
Discussion started by: fwellers
3 Replies

3. Shell Programming and Scripting

Assigning a specific format to a specific column in a text file using awk and printf

Hi, I have the following text file: 8 T1mapping_flip02 ok 128 108 30 1 665000-000008-000001.dcm 9 T1mapping_flip05 ok 128 108 30 1 665000-000009-000001.dcm 10 T1mapping_flip10 ok 128 108 30 1 665000-000010-000001.dcm 11 T1mapping_flip15 ok 128 108 30... (2 Replies)
Discussion started by: goodbenito
2 Replies

4. Shell Programming and Scripting

Using Awk for extracting data in specific format

please help me writing a awk script 001_r.pdb 0.0265185 001_r.pdb 0.0437049 001_r.pdb 0.0240642 001_r.pdb 0.0310264 001_r.pdb 0.0200482 001_r.pdb 0.0146746 001_r.pdb 0.0351344 001_r.pdb 0.0347856 001_r.pdb 0.036119 001_r.pdb 1.49 002_r.pdb 0.0281011 002_r.pdb 0.0319908 002_r.pdb... (5 Replies)
Discussion started by: phoenix_nebula
5 Replies

5. Shell Programming and Scripting

Need help in writing a script to create a new text file with specific data from existing two files

Hi, I have two text files. Need to create a third text file extracting specific data from first two existing files.. Text File 1: Format contains: SQL*Loader: Release 10.2.0.1.0 - Production on Wed Aug 4 21:06:34 2010 some text ............so on...and somwhere text like: Record 1:... (1 Reply)
Discussion started by: shashi143ibm
1 Replies

6. Shell Programming and Scripting

[SOLVED] Converting data from one format to the other

Hi All, I need to convert an exel spreadsheet into a SAS dataset, and the following format change is needed. Please help, this is too complex for a biologist. Let me describe the input. 1st row is generation.1st column in keyword 'generation', starting 2nd column there are 5... (9 Replies)
Discussion started by: newbie83
9 Replies

7. Shell Programming and Scripting

Need script for transferring bulk files from one format to text format

"Help Me" Need script for transferring bulk files from one format to text format in a unix server. Please suggest (2 Replies)
Discussion started by: Kranthi Kumar
2 Replies

8. Shell Programming and Scripting

Script for converting to xls and to mail the same

i have installed CENTOS in VMware. I want the linux command to run in CENTOS. The command is to select data's from Event table(our table name) convert into .xls and mail every 2hrs. Can you please help me in writing this script. Thanks, Shobana (1 Reply)
Discussion started by: shobana praveen
1 Replies

9. Shell Programming and Scripting

How to convert Text data to xls?

Hi Team, I have created a script to output DB Query data to a text file. It displays output as follows for 2 different queries appended to same file. I want help to convert this data to xls format so that the output of first query is in 1 tab and the other in second tab. Please help. ... (14 Replies)
Discussion started by: srkmish
14 Replies

10. UNIX for Advanced & Expert Users

Converting xls file to xlsx on UNIX script / command line.

Hi All, Am needing advise on how to convert xls file to xlsx format on Solaris unix command line or scripting. I tried searching online but it looks like I need to either use Perl packages of Excel or Python packages or some other 3rd party tool. Problem is to install any of these will require... (2 Replies)
Discussion started by: arvindshukla81
2 Replies
RDF::Query::Federate(3pm)				User Contributed Perl Documentation				 RDF::Query::Federate(3pm)

NAME
RDF::Query::Federate - A subclass of RDF::Query for efficient federated query execution. VERSION
This document describes RDF::Query::Federate version 2.908. SYNOPSIS
my $service = RDF::Query::ServiceDescription->new( $url ); my $query = new RDF::Query::Federate ( $sparql ); $query->add_service( $service ); my $stream = $query->execute(); DESCRIPTION
... METHODS
"new ( $query, \%options )" "new ( $query, $base_uri, $languri, $lang )" Returns a new RDF::Query::Federate object for the specified $query. The query language defaults to SPARQLP, but may be set specifically by specifying either $languri or $lang, whose acceptable values are: $lang: 'rdql', 'sparql11', or 'sparql' $languri: 'http://www.w3.org/TR/rdf-sparql-query/', or 'http://jena.hpl.hp.com/2003/07/query/RDQL' "add_service ( $service_description )" Adds the service described by $service_description to the query's list of data sources. "services" "algebra_fixup ( $algebra, $bridge, $base_uri, $ns )" Called in the fixup method of ::Algebra classes, returns either an optimized ::Algebra object ready for execution, or undef (in which case it will be prepared for execution by the ::Algebra::* class itself. AUTHOR
Gregory Todd Williams <gwilliams@cpan.org> perl v5.14.2 2012-01-31 RDF::Query::Federate(3pm)
All times are GMT -4. The time now is 05:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy