I have a strange situation of sorting and merging two files based on similar columns
previusly both files has same count of records so, I made below way which is working fine until they reduced the count of one files .
I.e. some times the count of records of both will same and some times it won't but only the columns will remain unchanged .
Code:
cat /var/tmp/today.csv > /var/tmp/outputfile
for file in `ls /var/tmp/yday.csv | xargs `
do
cut -d"," -f7,8,9 $file > /var/tmp/tmp
paste -d"," /var/tmp/outputfile /var/tmp/tmp >> /var/tmp/final_outputfile
done
working well for same row count files
and columns we are talking about are 1,2,3,5,6 which are common in both files.
now files has changed
for today
Code:
36000807 A 123 78 0 1 0.1 0.2 0.3
36000807 A 123 79 0 1 -0.1 0.2 -0.3
36000807 A 123 78 0 5 0.1 0.2 0.3
36000807 A 123 79 0 5 -0.1 0.2 -0.3
36000807 A 123 78 0 10 0.1 0.2 0.3
36000807 A 123 79 0 10 -0.1 0.2 -0.3
for yday.csv
Code:
36000807 A 123 76 0 1 0.1 0.2 0.3
36000807 A 123 76 0 5 -0.1 0.2 -0.3
36000807 A 123 76 0 10 -0.1 0.2 -0.3
now final_outputfile
should looklike
Code:
36000807 A 123 78 0 1 0.1 0.2 0.3 0.1 0.2 0.3
36000807 A 123 79 0 1 -0.1 0.2 -0.3 NA NA NA
36000807 A 123 78 0 5 0.1 0.2 0.3 -0.1 0.2 -0.3
36000807 A 123 79 0 5 -0.1 0.2 -0.3 NA NA NA
36000807 A 123 78 0 10 0.1 0.2 0.3 -0.1 0.2 -0.3
36000807 A 123 79 0 10 -0.1 0.2 -0.3 NA NA NA
it's possible for yday.csv first row could be missing totally or any other rows
then
final_output should be looklike
Code:
36000807 A 123 78 0 1 0.1 0.2 0.3 NA NA NA
36000807 A 123 79 0 1 -0.1 0.2 -0.3 NA NA NA
36000807 A 123 78 0 5 0.1 0.2 0.3 -0.1 0.2 -0.3
36000807 A 123 79 0 5 -0.1 0.2 -0.3 NA NA NA
36000807 A 123 78 0 10 0.1 0.2 0.3 -0.1 0.2 -0.3
36000807 A 123 79 0 10 -0.1 0.2 -0.3 NA NA NA
Hey,
I have a problem with nslookup under the newly installed mandrake 9.1, and as I see now also under Redhat 8.0
I have a pc called evo with the ip 10.0.0.1 which entered correctly in the /etc/hosts file. Connection to the internet is via an adsl-router. I have the nameservers from my... (2 Replies)
Hi All,
I am writing some data's into a file from C++ program. The files which i am writing is of fixed length . say 232 in length per line.
I am writing as . my c code is as
... (0 Replies)
Hi
All,
How can you sort a file that is doubled space ( where even number lines are blank lines) and still preserves the blank lines?
You can use grep,sed and regular expression.
Thanks
Vishal (4 Replies)
I have 2 files
file1.txt
a 123 aqsw
c 234 sfdr
fil2.txt
b 345 hgy
d 4653 jgut
I want to merger in such a manner the the output file should be
outfile.txt
a 123 aqsw
b 345 hgy
c 234 sfdr
d 4653 jgut
Do we have any command to achive this? (8 Replies)
Hi All:
I have following files:
File 1:
<header>
text...
text ..
text ..
text ..
<\header>
x
y
z
...
File 2:
<header>
text...
text ..
text .. (4 Replies)
Hi everyone, need your help in sorting and merging two numerical lists
Example:
I have one list 1 2 3 4 5 7 and the other 4 6 8, then the final output should be 1 2 3 4 5 6 7 8
Requesting your kind help in this
Regards,
RB :) (1 Reply)
Hi
I’m new to scripting and have only had about two days experience with this. I have questions about a bash/gawk script.
Problem:
I have 27 files, which needs to get merged into one, the files are separated into 8 subdivisions containing a 3 row data description. Example of data
File.1
... (7 Replies)
Hello,
I have a master database of a dictionary with the following structure:
a=b (b is a Unicode string)
a is the English part and b is the equivalent in a foreign language
I have also another file which has a database where the /b/ part of the string has been corrected by an expert. let us... (5 Replies)
Dear All, I have two file like this:
file1:
a1234
b1235
c4678
d7859
file2 :
e4575
f7869
g7689
h9687
I want output like this:
a1234
b1235
c4678 (2 Replies)
I have the following files:
file A
Col1 Col2
A 1
B 2
C 3
D 4
file B
Col1 Col2
A 1
Aa 1
B 2
C 3
D 4
file C
Col1 Col2
A 1 (1 Reply)
Discussion started by: ramky79
1 Replies
LEARN ABOUT PHP
msgfmt_format_message
MSGFMT_FORMAT_MESSAGE(3) 1 MSGFMT_FORMAT_MESSAGE(3)MessageFormatter::formatMessage - Quick format message
Object oriented style
SYNOPSIS
publicstatic string MessageFormatter::formatMessage (string $locale, string $pattern, array $args)
DESCRIPTION
Procedural style
string msgfmt_format_message (string $locale, string $pattern, array $args)
Quick formatting function that formats the string without having to explicitly create the formatter object. Use this function when the
format operation is done only once and does not need and parameters or state to be kept.
PARAMETERS
o $locale
- The locale to use for formatting locale-dependent parts
o $pattern
- The pattern string to insert things into. The pattern uses an 'apostrophe-friendly' syntax; it is run through umsg_autoQuoteA-
postrophe before being interpreted.
o $args
- The array of values to insert into the format string
RETURN VALUES
The formatted pattern string or FALSE if an error occurred
EXAMPLES
Example #1
msgfmt_format_message(3) example
<?php
echo msgfmt_format_message("en_US", "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree
", array(4560, 123, 4560/123));
echo msgfmt_format_message("de", "{0,number,integer} Affen auf {1,number,integer} Baumen sind {2,number} Affen pro Baum
", array(4560, 123, 4560/123));
?>
Example #2
OO example
<?php
echo MessageFormatter::formatMessage("en_US", "{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree
", array(4560, 123, 4560/123));
echo MessageFormatter::formatMessage("de", "{0,number,integer} Affen auf {1,number,integer} Baumen sind {2,number} Affen pro Baum
", array(4560, 123, 4560/123));
?>
The above example will output:
4,560 monkeys on 123 trees make 37.073 monkeys per tree
4.560 Affen auf 123 Baumen sind 37,073 Affen pro Baum
SEE ALSO msgfmt_create(3), msgfmt_parse(3), msgfmt_get_error_code(3), msgfmt_get_error_message(3).
PHP Documentation Group MSGFMT_FORMAT_MESSAGE(3)