Sponsored Content
Top Forums Shell Programming and Scripting Converting Pivot file to flat file Post 86957 by Perderabo on Tuesday 18th of October 2005 04:20:37 PM
Old 10-18-2005
Maybe...
Code:
#! /usr/bin/ksh

read one
while read field line ; do
        echo "$field ${one%% *} $line"
        one=${one#* }
done
exit 0

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting Column to Rows in a Flat file

Hi, Request To guide me in writing a shell program for the following requirement: Example:if the Input File contains the follwing data Input File Data: 80723240029,12,323,443,88,98,7,98,67,87 80723240030,12,56,6,,,3,12,56,6,7,2,3,12,56,6,7,2,3,88,98,7,98,67,87... (5 Replies)
Discussion started by: srinikal
5 Replies

2. Shell Programming and Scripting

Pivot file contents

Hi All, I am trying to pivot the contents in a file. Ex: I have a file sample.txt with data "A B C D", i need the contents to pivot & resulting file should look like "A B C ... (3 Replies)
Discussion started by: new_ds_man
3 Replies

3. Shell Programming and Scripting

Converting a flat file in XML

Hello Friends, I am new to UNIX shell scripting. Using bash....Could you please help me in converting a flat file into an XML style output file. Flat file: (Input File entries looks like this) John Miller: 617-569-7996:15 Bunting lane, staten Island, NY: 10/21/79: 60600 The... (4 Replies)
Discussion started by: humkhn
4 Replies

4. UNIX for Advanced & Expert Users

Converting the date format in a flat file

Hi All, I am new to this forum, could any one help me out in resolving the below issue. Input of the flat file contains several lines of text for example find below: 5022090,2,4,7154,88,,,,,4/1/2011 0:00,Z,L,2 5022090,3,1,6648,88,,,,,4/1/2011 0:00,Z,,1... (0 Replies)
Discussion started by: av_sagar
0 Replies

5. UNIX for Dummies Questions & Answers

Script to pivot flat file

Hi to all, I have a file with a list of values: v1,v2,v3....,v9 need file in this format: Name1: v1 Name2: v2 Name3: v3 ... Name9: v9 Please help me out. (2 Replies)
Discussion started by: mozi
2 Replies

6. Shell Programming and Scripting

Help with converting XML to Flat file

Hi Friends, I want to convert a XML file to flat file. Sample I/p: <?xml version='1.0' encoding='UTF-8' ?> <DataFile xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' contactCount='4999' date='2012-04-14' time='22:00:14' xsi:noNamespaceSchemaLocation='gen .xsd'> <Contact... (3 Replies)
Discussion started by: karumudi7
3 Replies

7. Shell Programming and Scripting

Pivot file content

Hi All , I have a file as below . A "1" B "2" C "3" D "4" E "5" F "6" A "11" B "21" C "31" D "41" E "51" F "61" And the output should be like A B C D E F 1 2 3 4 5 6 11 21 31 41 51 (8 Replies)
Discussion started by: saj
8 Replies

8. Shell Programming and Scripting

Oracle table extract: all columns are not converting into pipe delimited in flat file

Hi All, I am writing a shell script to extract oracle table into a pipe dilemited flat file. Below is my code and I have attached two files that I have abled to generate so far. 1. Table.txt ==> database extract file 2. flat.txt ==> pipe delimited after some manipulation of the original db... (5 Replies)
Discussion started by: express14
5 Replies

9. Shell Programming and Scripting

Pivot file using shellscript

Hi, I am new at using shell scripting. So I have a question for the more experienced Linux users. I would like to perform some kind of pivot on a file. Example Input file COL1,"2001-01-01","2001-03-01","2001-03-24" A1,22,,44 B1,56,78,12 C2,5,, I would like to have to following output... (2 Replies)
Discussion started by: shanlinux
2 Replies

10. Shell Programming and Scripting

Converting csv file to flat file

Hi All, I have a csv file which is comma seperated. I need to convert to flat file with preferred column length country,id Australia,1234 Africa,12399999 Expected output country id Australia 1234 Africa 12399999 the flat file should predefined length on respective... (8 Replies)
Discussion started by: rohit_shinez
8 Replies
math::interpolate(n)						 Tcl Math Library					      math::interpolate(n)

__________________________________________________________________________________________________________________________________________________

NAME
math::interpolate - Interpolation routines SYNOPSIS
package require Tcl ?8.4? package require struct package require math::interpolate ?1.0.2? ::math::interpolate::defineTable name colnames values ::math::interpolate::interp-1d-table name xval ::math::interpolate::interp-table name xval yval ::math::interpolate::interp-linear xyvalues xval ::math::interpolate::interp-lagrange xyvalues xval ::math::interpolate::prepare-cubic-splines xcoord ycoord ::math::interpolate::interp-cubic-splines coeffs x ::math::interpolate::interp-spatial xyvalues coord ::math::interpolate::interp-spatial-params max_search power ::math::interpolate::neville xlist ylist x _________________________________________________________________ DESCRIPTION
This package implements several interpolation algorithms: o Interpolation into a table (one or two independent variables), this is useful for example, if the data are static, like with tables of statistical functions. o Linear interpolation into a given set of data (organised as (x,y) pairs). o Lagrange interpolation. This is mainly of theoretical interest, because there is no guarantee about error bounds. One possible use: if you need a line or a parabola through given points (it will calculate the values, but not return the coefficients). A variation is Neville's method which has better behaviour and error bounds. o Spatial interpolation using a straightforward distance-weight method. This procedure allows any number of spatial dimensions and any number of dependent variables. o Interpolation in one dimension using cubic splines. This document describes the procedures and explains their usage. PROCEDURES
The interpolation package defines the following public procedures: ::math::interpolate::defineTable name colnames values Define a table with one or two independent variables (the distinction is implicit in the data). The procedure returns the name of the table - this name is used whenever you want to interpolate the values. Note: this procedure is a convenient wrapper for the struct::matrix procedure. Therefore you can access the data at any location in your program. string name (in) Name of the table to be created list colnames (in) List of column names list values (in) List of values (the number of elements should be a multiple of the number of columns. See EXAMPLES for more information on the interpretation of the data. The values must be sorted with respect to the independent variable(s). ::math::interpolate::interp-1d-table name xval Interpolate into the one-dimensional table "name" and return a list of values, one for each dependent column. string name (in) Name of an existing table float xval (in) Value of the independent row variable ::math::interpolate::interp-table name xval yval Interpolate into the two-dimensional table "name" and return the interpolated value. string name (in) Name of an existing table float xval (in) Value of the independent row variable float yval (in) Value of the independent column variable ::math::interpolate::interp-linear xyvalues xval Interpolate linearly into the list of x,y pairs and return the interpolated value. list xyvalues (in) List of pairs of (x,y) values, sorted to increasing x. They are used as the breakpoints of a piecewise linear function. float xval (in) Value of the independent variable for which the value of y must be computed. ::math::interpolate::interp-lagrange xyvalues xval Use the list of x,y pairs to construct the unique polynomial of lowest degree that passes through all points and return the interpo- lated value. list xyvalues (in) List of pairs of (x,y) values float xval (in) Value of the independent variable for which the value of y must be computed. ::math::interpolate::prepare-cubic-splines xcoord ycoord Returns a list of coefficients for the second routine interp-cubic-splines to actually interpolate. list xcoord List of x-coordinates for the value of the function to be interpolated is known. The coordinates must be strictly ascending. At least three points are required. list ycoord List of y-coordinates (the values of the function at the given x-coordinates). ::math::interpolate::interp-cubic-splines coeffs x Returns the interpolated value at coordinate x. The coefficients are computed by the procedure prepare-cubic-splines. list coeffs List of coefficients as returned by prepare-cubic-splines float x x-coordinate at which to estimate the function. Must be between the first and last x-coordinate for which values were given. ::math::interpolate::interp-spatial xyvalues coord Use a straightforward interpolation method with weights as function of the inverse distance to interpolate in 2D and N-dimensional space The list xyvalues is a list of lists: { {x1 y1 z1 {v11 v12 v13 v14}} {x2 y2 z2 {v21 v22 v23 v24}} ... } The last element of each inner list is either a single number or a list in itself. In the latter case the return value is a list with the same number of elements. The method is influenced by the search radius and the power of the inverse distance list xyvalues (in) List of lists, each sublist being a list of coordinates and of dependent values. list coord (in) List of coordinates for which the values must be calculated ::math::interpolate::interp-spatial-params max_search power Set the parameters for spatial interpolation float max_search (in) Search radius (data points further than this are ignored) integer power (in) Power for the distance (either 1 or 2; defaults to 2) ::math::interpolate::neville xlist ylist x Interpolates between the tabulated values of a function whose abscissae are xlist and whose ordinates are ylist to produce an esti- mate for the value of the function at x. The result is a two-element list; the first element is the function's estimated value, and the second is an estimate of the absolute error of the result. Neville's algorithm for polynomial interpolation is used. Note that a large table of values will use an interpolating polynomial of high degree, which is likely to result in numerical instabilities; one is better off using only a few tabulated values near the desired abscissa. EXAMPLES
TODO Example of using the cubic splines: Suppose the following values are given: x y 0.1 1.0 0.3 2.1 0.4 2.2 0.8 4.11 1.0 4.12 Then to estimate the values at 0.1, 0.2, 0.3, ... 1.0, you can use: set coeffs [::math::interpolate::prepare-cubic-splines {0.1 0.3 0.4 0.8 1.0} {1.0 2.1 2.2 4.11 4.12}] foreach x {0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0} { puts "$x: [::math::interpolate::interp-cubic-splines $coeffs $x]" } to get the following output: 0.1: 1.0 0.2: 1.68044117647 0.3: 2.1 0.4: 2.2 0.5: 3.11221507353 0.6: 4.25242647059 0.7: 5.41804227941 0.8: 4.11 0.9: 3.95675857843 1.0: 4.12 As you can see, the values at the abscissae are reproduced perfectly. BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category math :: interpolate of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. KEYWORDS
interpolation, math, spatial interpolation CATEGORY
Mathematics COPYRIGHT
Copyright (c) 2004 Arjen Markus <arjenmarkus@users.sourceforge.net> Copyright (c) 2004 Kevn B. Kenny <kennykb@users.sourceforge.net> math 1.0.2 math::interpolate(n)
All times are GMT -4. The time now is 05:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy