Sponsored Content
Top Forums Shell Programming and Scripting recoding data points using SED?? Post 302360636 by steadyonabix on Friday 9th of October 2009 02:11:15 PM
Old 10-09-2009
Confused

I have read this post a number of times and have to say I am confused.

It would be better if you put a representative file together containing all input variations you need to account for.

Then put a file together showing the desired output for that input file.

Clearly define any conventions you use and try to avoid explaining how it will be achieved, just explain what you want.

Good luck
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

to extarct data points

suppose u have a file which consist of many data points separated by asterisk Question is to extract third part in each line . 0.0002*0.003*-0.93939*0.0202*0.322*0.3332*0.2222*0.22020 0.003*0.3333*0.33322*-0.2220*0.3030*0.2222*0.3331*-0.3030 0.0393*0.3039*-0.03038*0.033*0.4033*0.30384*0.4048... (5 Replies)
Discussion started by: cdfd123
5 Replies

2. Shell Programming and Scripting

Writing an algorithm to recode data points

I have a file that has been partially recoded so that data points that were formerly letter combinations are now -1, 0, or 1. I need to finish recoding the GG and CC data points. The file looks like this: ID 1 2 3 4 5 6 7 8 83845676 0 0 0 0 CC -1 CC CC 838469. -1 -1 1 GG CC 0 CC 1 83847041... (10 Replies)
Discussion started by: doobedoo
10 Replies

3. Shell Programming and Scripting

Group search (multiple data points) in Linux

Hi All I have a data set like this tab delimited: weft fgr-1 345 -1 fgrythdgd weft fgr-3 456 -2 ghjdklflllff weft fgr-11 456 -3 ghtjuffl weft fgr-1 213 -2 ghtyjdkl weft fgr-34 567 -5 fghytkflf frgt fgr-36 567 -1 ghrjufjf frgt fgr-45 678 -2 ghjruir frgt fgr-34 546 -5 gjjjgkldlld frgt... (4 Replies)
Discussion started by: Lucky Ali
4 Replies

4. UNIX for Dummies Questions & Answers

How to get data only inside polygon created by points which is part of whole data from file?

hiii, Help me out..i have a huge set of data stored in a file.This file has has 2 columns which is latitude & longitude of a region. Now i have a program which asks for the number of points & based on this number it asks the user to enter that latitude & longitude values which are in the same... (7 Replies)
Discussion started by: reva
7 Replies

5. Programming

GNUPLOT- how to change the style of data points

Hi, I am trying to arrange my graphs with GNUPLOT. Although it looked like simple at the beginning, I could not figure out an answer for the following: I want to change the style of my data points (not the line, just exact data points) The terminal assigns first + and then x to them but what I... (0 Replies)
Discussion started by: natasha
0 Replies

6. Shell Programming and Scripting

Calculate difference between consecutive data points in a column from a file

Hi, I have a file with one column data (sample below) and I am trying to write a shell script to calculate the difference between consecutive data valuse i.e Var = Ni -N(i-1) 0.3141 -3.6595 0.9171 5.2001 3.5331 3.7022 -6.1087 -5.1039 -9.8144 1.6516 -2.725 3.982 7.769 8.88 (5 Replies)
Discussion started by: malandisa
5 Replies

7. UNIX for Dummies Questions & Answers

Finding data value that contains x% of points

Hi, I need help on finding the value of my data that encompasses certain percentage of my total data points (n). Attached is an example of my data, n=30. What I want to do is for instance is find the minimum threshold that still encompasses 60% (n=18), 70% (n=21) and 80% (n=24). manually to... (4 Replies)
Discussion started by: ida1215
4 Replies

8. Shell Programming and Scripting

Grabbing data between 2 points in text file

I have a text file that shows the output of my solar inverters. I want to separate this into sections. overview , device 1 , device 2 , device 3. Each device has different number of lines. but they all have unique starting points. Overview starts with 6 #'s, Devices have 4#'s and their data starts... (6 Replies)
Discussion started by: Mikey
6 Replies

9. Shell Programming and Scripting

Recoding data in a matrix from an existing file

Hi, I was wondering if someone would be able to help with extrapolating information from a file and filling an existing matrix with that information. I have made a matrix like this (file 1): A B C D 1 2 3 4 I have another file with data like this (file 2): 1 A 1 C 3 C 4 B... (1 Reply)
Discussion started by: hubleo
1 Replies

10. Shell Programming and Scripting

Ranking data points from multiple files

I need to rank a large number of data points that exist in multiple files. My data points (Column 3) are based on unique values in columns 1 and 2. I need to rank the values that are in File 1, Column 3. For instance: Input File 1 AAA BBB 10 CCC DDD 16 EEE FFF 20 Input File 2 ... (47 Replies)
Discussion started by: ncwxpanther
47 Replies
YAWriter(3)						User Contributed Perl Documentation					       YAWriter(3)

NAME
XML::Handler::YAWriter - Yet another Perl SAX XML Writer SYNOPSIS
use XML::Handler::YAWriter; my $ya = new XML::Handler::YAWriter( %options ); my $perlsax = new XML::Parser::PerlSAX( 'Handler' => $ya ); DESCRIPTION
YAWriter implements Yet Another XML::Handler::Writer. The reasons for this one are that I needed a flexible escaping technique, and want some kind of pretty printing. If an instance of YAWriter is created without any options, the default behavior is to produce an array of strings containing the XML in : @{$ya->{Strings}} Options Options are given in the usual 'key' => 'value' idiom. Output IO::File This option tells YAWriter to use an already open file for output, instead of using $ya->{Strings} to store the array of strings. It should be noted that the only thing the object needs to implement is the print method. So anything can be used to receive a stream of strings from YAWriter. AsFile string This option will cause start_document to open named file and end_document to close it. Use the literal dash "-" if you want to print on standard output. AsPipe string This option will cause start_document to open a pipe and end_document to close it. The pipe is a normal shell command. Secure shell comes handy but has a 2GB limit on most systems. AsArray boolean This option will force storage of the XML in $ya->{Strings}, even if the Output option is given. AsString boolean This option will cause end_document to return the complete XML document in a single string. Most SAX drivers return the value of end_document as a result of their parse method. As this may not work with some combinations of SAX drivers and filters, a join of $ya->{Strings} in the controlling method is preferred. Encoding string This will change the default encoding from UTF-8 to anything you like. You should ensure that given data are already in this encoding or provide an Escape hash, to tell YAWriter about the recoding. Escape hash The Escape hash defines substitutions that have to be done to any string, with the exception of the processing_instruction and doctype_decl methods, where I think that escaping of target and data would cause more trouble than necessary. The default value for Escape is $XML::Handler::YAWriter::escape = { '&' => '&amp;', '<' => '&lt;', '>' => '&gt;', '"' => '&quot;', '--' => '&#45;&#45;' }; YAWriter will use an evaluated sub to make the recoding based on a given Escape hash reasonably fast. Future versions may use XS to improve this performance bottleneck. Pretty hash Hash of string => boolean tuples, to define kind of prettyprinting. Default to undef. Possible string values: AddHiddenNewline boolean Add hidden newline before ">" AddHiddenAttrTab boolean Add hidden tabulation for attributes CatchEmptyElement boolean Catch empty Elements, apply "/>" compression CatchWhiteSpace boolean Catch whitespace with comments CompactAttrIndent Places Attributes on the same line as the Element IsSGML boolean This option will cause start_document, processing_instruction and doctype_decl to appear as SGML. The SGML is still well-formed of course, if your SAX events are well-formed. NoComments boolean Supress Comments NoDTD boolean Supress DTD NoPI boolean Supress Processing Instructions NoProlog boolean Supress <?xml ... ?> Prolog NoWhiteSpace boolean Supress WhiteSpace to clean documents from prior pretty printing. PrettyWhiteIndent boolean Add visible indent before any eventstring PrettyWhiteNewline boolean Add visible newlines before any eventstring SAX1 boolean (not yet implemented) Output only SAX1 compliant eventstrings Notes: Correct handling of start_document and end_document is required! The YAWriter Object initialises its structures during start_document and does its cleanup during end_document. If you forget to call start_document, any other method will break during the run. Most likely place is the encode method, trying to eval undef as a subroutine. If you forget to call end_document, you should not use a single instance of YAWriter more than once. For small documents AsArray may be the fastest method and AsString the easiest one to receive the output of YAWriter. But AsString and AsArray may run out of memory with infinite SAX streams. The only method XML::Handler::Writer calls on a given Output object is the print method. So it's easy to use a self written Output object to improve streaming. A single instance of XML::Handler::YAWriter is able to produce more than one file in a single run. Be sure to provide a fresh IO::File as Output before you call start_document and close this File after calling end_document. Or provide a filename in AsFile, so start_document and end_document can open and close its own filehandle. Automatic recoding between 8bit and 16bit does not work in any Perl correctly ! I have Perl-5.00563 at home and here I can specify "use utf8;" in the right places to make recoding work. But I dislike saying "use 5.00555;" because many systems run 5.00503. If you use some 8bit character set internally and want use national characters, either state your character as Encoding to be ISO-8859-1, or provide an Escape hash similar to the following : $ya->{'Escape'} = { '&' => '&amp;', '<' => '&lt;', '>' => '&gt;', '"' => '&quot;', '--' => '&#45;&#45;' 'oe' => '&ouml;' 'ae' => '&auml;' 'ue' => '&uuml;' 'Oe' => '&Ouml;' 'Ae' => '&Auml;' 'Ue' => '&Uuml;' 'ss' => '&szlig;' }; You may abuse YAWriter to clean whitespace from XML documents. Take a look at test.pl, doing just that with an XML::Edifact message, without querying the DTD. This may work in 99% of the cases where you want to get rid of ignorable whitespace caused by the various forms of pretty printing. my $ya = new XML::Handler::YAWriter( 'Output' => new IO::File ( ">-" ); 'Pretty' => { 'NoWhiteSpace'=>1, 'NoComments'=>1, 'AddHiddenNewline'=>1, 'AddHiddenAttrTab'=>1, } ); XML::Handler::Writer implements any method XML::Parser::PerlSAX wants. This extends the Java SAX1.0 specification. I have in mind using Pretty=>SAX1=>1 to disable this feature, if abusing YAWriter for a SAX proxy. AUTHOR
Michael Koehne, Kraehe@Copyleft.De Thanks "Derksen, Eduard (Enno), CSCIO" <enno@att.com> helped me with the Escape hash and gave quite a lot of useful comments. SEE ALSO
perl and XML::Parser::PerlSAX perl v5.16.3 2014-06-10 YAWriter(3)
All times are GMT -4. The time now is 04:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy