i am studying a script which is used for data loading.
it has functions which deletes all the existing data before loading and then loads new fresh data.
but i am stuck up at function Replace into table ( col 1,col 2....)
Does this signify All Inserts. (1 Reply)
I have a 1 million record file and in there i have 580 bad records meaning like they were spread on to 2 lines and is making my process fail as it is expecting single line records. How can i correct this records spread into 2 lines into single line or how i can writer these records into a new... (34 Replies)
Hi everyone!
Can you please help me with some shell scripting?
I have an input file input.txt
It has 3 columns (Time, Event, Value)
Time event Value
03:38:22 A 57
03:38:23 A 56
03:38:24 B 24
03:38:25 C 51
03:38:26 B 7
03:38:26 ... (7 Replies)
I could not find this on the search..
I want to know how to trim a row
so lets say I have a file that looks like this:
bob 88888888888888
and I want to trim column 2 (lets say 4 off the front and end)
bob 888888
Also, how would I bin column 2
Lets so I want to add and average... (1 Reply)
Hi I have a file that I want to bin.
I am using this code:
awk -F'\t' -v r=40 '{for(i=r;i<=NF;i+=r){for(j=0;j<r;j++){sum+=$(i-j)}printf "%s ", sum/r;sum=0}; printf "\n"}' file1 > file2
So basically what this code does is that it will averaging every 40 columns (creating bins of 40). But... (2 Replies)
Hi all,
suppose i have one file and in that file there are thousand of record like below . if i want to fill the bold position below with some value suppose 000000 then how it would be in shell script
... (1 Reply)
Hi All,
I'm having a problem tabbing the data. can you please help me tab the data. i used sed but it's not working.
ex.
BUNDLE1MB(6spaces)|Y|ng_oliv10@shellscript.com.ph(6spaces)562.60.61.20(6spaces)562.61.35
here's my code
sed "s/ //g" Userid_dsl_npm.txt__200 | sed "s/ |/ /g" |... (2 Replies)
Hello
I have a text file with tens of thousands of rows
The format is
x y
where both x and y can be anything between -100 and +100.
What I would like to do is have a 3d gnuplot where there are 10,000 squared or bins and each bin will count how many rows have a value that would be... (1 Reply)
Discussion started by: garethsays
1 Replies
LEARN ABOUT DEBIAN
data::munge
Data::Munge(3pm) User Contributed Perl Documentation Data::Munge(3pm)NAME
Data::Munge - various utility functions
SYNOPSIS
use Data::Munge;
my $re = list2re qw/foo bar baz/;
print byval { s/foo/bar/ } $text;
foo(mapval { chomp } @lines);
print replace('Apples are round, and apples are juicy.', qr/apples/i, 'oranges', 'g');
print replace('John Smith', qr/(w+)s+(w+)/, '$2, $1');
DESCRIPTION
This module defines a few generally useful utility functions. I got tired of redefining or working around them, so I wrote this module.
Functions
list2re LIST
Converts a list of strings to a regex that matches any of the strings. Especially useful in combination with "keys". Example:
my $re = list2re keys %hash;
$str =~ s/($re)/$hash{$1}/g;
byval BLOCK SCALAR
Takes a code block and a value, runs the block with $_ set to that value, and returns the final value of $_. The global value of $_ is
not affected. $_ isn't aliased to the input value either, so modifying $_ in the block will not affect the passed in value. Example:
foo(byval { s/!/?/g } $str);
# Calls foo() with the value of $str, but all '!' have been replaced by '?'.
# $str itself is not modified.
mapval BLOCK LIST
Works like a combination of "map" and "byval"; i.e. it behaves like "map", but $_ is a copy, not aliased to the current element, and
the return value is taken from $_ again (it ignores the value returned by the block). Example:
my @foo = mapval { chomp } @bar;
# @foo contains a copy of @bar where all elements have been chomp'd.
# This could also be written as chomp(my @foo = @bar); but that's not
# always possible.
submatches
Returns a list of the strings captured by the last successful pattern match. Normally you don't need this function because this is
exactly what "m//" returns in list context. However, "submatches" also works in other contexts such as the RHS of "s//.../e".
replace STRING, REGEX, REPLACEMENT, FLAG
replace STRING, REGEX, REPLACEMENT
A clone of javascript's "String.prototype.replace". It works almost the same as "byval { s/REGEX/REPLACEMENT/FLAG } STRING", but with a
few important differences. REGEX can be a string or a compiled "qr//" object. REPLACEMENT can be a string or a subroutine reference. If
it's a string, it can contain the following replacement patterns:
$$ Inserts a '$'.
$& Inserts the matched substring.
$` Inserts the substring preceding the match.
$' Inserts the substring following the match.
$N (where N is a digit)
Inserts the substring matched by the Nth capturing group.
${N} (where N is one or more digits)
Inserts the substring matched by the Nth capturing group.
Note that these aren't variables; they're character sequences interpreted by "replace".
If REPLACEMENT is a subroutine reference, it's called with the following arguments: First the matched substring (like $& above), then
the contents of the capture buffers (as returned by "submatches"), then the offset where the pattern matched (like "$-[0]", see "@-" in
perlvar), then the STRING. The return value will be inserted in place of the matched substring.
Normally only the first occurrence of REGEX is replaced. If FLAG is present, it must be 'g' and causes all occurrences to be replaced.
AUTHOR
Lukas Mai, "<l.mai at web.de>"
COPYRIGHT & LICENSE
Copyright 2009-2011 Lukas Mai.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as
published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
perl v5.12.4 2011-08-03 Data::Munge(3pm)