Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Concatenate column data, grouped by row info Post 302455486 by cjcox on Tuesday 21st of September 2010 08:05:17 PM
Old 09-21-2010
I made the assumption that you have 3 columns of data... but here goes...

Code:
awk '
{
        if (NR == 1) { print;next; }
        if (val1 != "" && $1 != lastkey) {
                print lastkey " " val1 " " val2 " " val3;
                val1="";
                val2="";
                val3=""
        }

        lastkey=$1;
        val1=val1 $2;
        val2=val2 $3;
        val3=val3 $4;
}
END {
        if (val1 != "") {
                print lastkey " " val1 " " val2 " " val3;
        }
}'

You can put that into a script and redirect input with your data.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to concatenate a string in every row data of a file??

Please look into the example. My source file is like, 00,57,3,2008-07-24 06:30:06 10,1,8025171,"1M00",17907023,2008-07-23 18:16:58 10,2,8025171,"1M00",17907023,2008-07-23 18:17:01 99,184 What should i do if i want output like... hello,00,57,3,2008-07-24 06:30:06... (7 Replies)
Discussion started by: pkumar3
7 Replies

2. Shell Programming and Scripting

Convert row data to column data

Hi Guys, I have a file as follows: a 1 b 786 c 90709 d 99 a 9875 b 989 c 887 d 111 I want: a 1 9875 b 786 989 (3 Replies)
Discussion started by: npatwardhan
3 Replies

3. Shell Programming and Scripting

row to column and position data in to fixed column width

Dear friends, Below is my program and current output. I wish to have 3 or 4 column output in order to accomodate in single page. i do have subsequent command to process after user enter the number. Program COUNT=1 for MYDIR in `ls /` do VOBS=${MYDIR} echo "${COUNT}. ${MYDIR}" ... (4 Replies)
Discussion started by: baluchen
4 Replies

4. Shell Programming and Scripting

Moving data from a specified column/row to another column/row

Hello, I have an input file like the following: 11_3_4 2_1_35 3_15__ _16989 Where '_' is a space. The data is in a table. Is there a way for the program to prompt the user for x1,y1 and x2,y2, where x1,y1 is the desired number (for example x=6 y=4 is a value of 4) and move to a desired spot... (2 Replies)
Discussion started by: jl487
2 Replies

5. Shell Programming and Scripting

Sort data from column to row

Hi, I need somebody's help with sorting data with awk. I've got a file: 10 aaa 4584 12 bbb 6138 20 ccc 4417 21 ddd 7796 10 eee 7484 12 fff ... (5 Replies)
Discussion started by: killerbee
5 Replies

6. UNIX for Advanced & Expert Users

Convert column data to row data using shell script

Hi, I want to convert a 3-column data to 3-row data using shell script. Any suggestion in this regard is highly appreciated. Thanks. (4 Replies)
Discussion started by: sktkpl
4 Replies

7. Shell Programming and Scripting

Convert Data from Column to Row

Hi FileA.txt E_TIM 16, ETE 15, EOND 26, EEC 81, E_1 un, E_2 un, E_3 un, E_4 284, E_TIM 17, ETE 15, EOND 29, EEC 82, E_1 un, E_2 un, E_3 un, E_4 249, (6 Replies)
Discussion started by: asavaliya
6 Replies

8. Shell Programming and Scripting

Replace First Column and First Row Data

HI Guys, I just want to replace data for First Column and Row Cell(1,1) Input :- Hello A B C X 1 2 3 Y 4 5 6 Z 7 8 9 Output:- Byee A B C X 1 2 3 Y 4 5 6 Z 7 8 9 From Hello to Byee .....And The Each file have Different String. (3 Replies)
Discussion started by: pareshkp
3 Replies

9. Shell Programming and Scripting

Column to Row Data.

HI Guys, I have below Input :- X L1 5 Y L1 10 Z L1 15 X L2 20 Y L2 12 Z L2 15 X L3 100 Y L3 Z L3 300 Output:- ID L1 L2 L3 X 5 10 15 Y 20 12 15 Z 100 Null 300 (11 Replies)
Discussion started by: pareshkp
11 Replies

10. Shell Programming and Scripting

Help with merge row if share same column info

Input file: 32568 SSO7483 32568 SSO7486 117231 SSO1293 117231 SSO1772 178081 SSO3076 178081 SSO3077 222417 porA-2 222417 porB-2 263778 SSO1245 263778 SSO0509 . . Desired output: 32568 SSO7483,SSO7486 117231 ... (3 Replies)
Discussion started by: perl_beginner
3 Replies
UDM_LOAD_ISPELL_DATA(3) 						 1						   UDM_LOAD_ISPELL_DATA(3)

udm_load_ispell_data - Load ispell data

SYNOPSIS
bool udm_load_ispell_data (resource $agent, int $var, string $val1, string $val2, int $flag) DESCRIPTION
udm_load_ispell_data(3) loads ispell data. After using this function to free memory allocated for ispell data, please use udm_free_ispell_data(3), even if you use UDM_ISPELL_TYPE_SERVER mode. PARAMETERS
o $agent - A link to Agent, received after call to udm_alloc_agent(3). o $var - Indicates the source for ispell data. May have the following values: o UDM_ISPELL_TYPE_DB - indicates that ispell data should be loaded from SQL. In this case, parameters $val1 and $val2 are ignored and should be left blank. $flag should be equal to 1. Note $flag indicates that after loading ispell data from defined source it should be sorted (it is necessary for correct functioning of ispell). In case of loading ispell data from files there may be several calls to udm_load_ispell_data(3), and there is no sense to sort data after every call, but only after the last one. Since in db mode all the data is loaded by one call, this parameter should have the value 1. In this mode in case of error, e.g. if ispell tables are absent, the function will return FALSE and code and error message will be accessible through udm_error(3) and udm_errno(3). o UDM_ISPELL_TYPE_AFFIX - indicates that ispell data should be loaded from file and initiates loading affixes file. In this case $val1 defines double letter language code for which affixes are loaded, and $val2 - file path. Please note, that if a relative path entered, the module looks for the file not in UDM_CONF_DIR, but in relation to current path, i.e. to the path where the script is executed. In case of error in this mode, e.g. if file is absent, the function will return FALSE, and an error message will be displayed. Error message text cannot be accessed through udm_error(3) and udm_errno(3), since those functions can only return messages associated with SQL. Please, see $flag parameter description in UDM_ISPELL_TYPE_DB. Example #1 udm_load_ispell_data(3) example <?php if ((! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_AFFIX, 'en', '/opt/ispell/en.aff', 0)) || (! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_AFFIX, 'ru', '/opt/ispell/ru.aff', 0)) || (! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_SPELL, 'en', '/opt/ispell/en.dict', 0)) || (! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_SPELL, 'ru', '/opt/ispell/ru.dict', 1))) { exit; } ?> Note $flag is equal to 1 only in the last call. o UDM_ISPELL_TYPE_SPELL - indicates that ispell data should be loaded from file and initiates loading of ispell dictionary file. In this case $val1 defines double letter language code for which affixes are loaded, and $val2 - file path. Please note, that if a relative path entered, the module looks for the file not in UDM_CONF_DIR, but in relation to current path, i.e. to the path where the script is executed. In case of error in this mode, e.g. if file is absent, the function will return FALSE, and an error message will be displayed. Error message text cannot be accessed through udm_error(3) and udm_errno(3), since those functions can only return messages associated with SQL. Please, see $flag parameter description in UDM_ISPELL_TYPE_DB. <?php if ((! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_AFFIX, 'en', '/opt/ispell/en.aff', 0)) || (! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_AFFIX, 'ru', '/opt/ispell/ru.aff', 0)) || (! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_SPELL, 'en', '/opt/ispell/en.dict', 0)) || (! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_SPELL, 'ru', '/opt/ispell/ru.dict', 1))) { exit; } ?> Note $flag is equal to 1 only in the last call. o UDM_ISPELL_TYPE_SERVER - enables spell server support. $val1 parameter indicates address of the host running spell server. $val2 ` is not used yet, but in future releases it is going to indicate number of port used by spell server. $flag parame- ter in this case is not needed since ispell data is stored on spellserver already sorted. Spelld server reads spell-data from a separate configuration file ( /usr/local/mnogosearch/etc/spelld.conf by default), sorts it and stores in memory. With clients server communicates in two ways: to indexer all the data is transferred (so that indexer starts faster), from search.cgi server receives word to normalize and then passes over to client (search.cgi) list of normalized word forms. This allows fastest, compared to db and text modes processing of search queries (by omitting loading and sorting all the spell data). udm_load_ispell_data(3) function in UDM_ISPELL_TYPE_SERVER mode does not actually load ispell data, but only defines server address. In fact, server is automatically used by udm_find(3) function when performing search. In case of errors, e.g. if spellserver is not running or invalid host indicated, there are no messages returned and ispell conversion does not work. Note This function is available in mnoGoSearch 3.1.12 or later. Example: <?php if (!udm_load_ispell_data($udm, UDM_ISPELL_TYPE_SERVER, '', '', 1)) { echo "Error loading ispell data from server<br /> "; exit; } ?> The fastest mode is UDM_ISPELL_TYPE_SERVER. UDM_ISPELL_TYPE_TEXT is slower and UDM_ISPELL_TYPE_DB is the slowest. The above pat- tern is TRUE for mnoGoSearch 3.1.10 - 3.1.11. It is planned to speed up DB mode in future versions and it is going to be faster than TEXT mode. o $val1 - o $val2 - o $flag - RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #2 udm_load_ispell_data(3) example <?php if (! udm_load_ispell_data($udm, UDM_ISPELL_TYPE_DB, '', '', 1)) { printf("Error #%d: '%s' ", udm_errno($udm), udm_error($udm)); exit; } ?> PHP Documentation Group UDM_LOAD_ISPELL_DATA(3)
All times are GMT -4. The time now is 01:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy