Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Split single record to multiple records Post 302601987 by bartus11 on Saturday 25th of February 2012 11:54:21 AM
Old 02-25-2012
Try:
Code:
awk -F"[,;]" -vOFS="," 'NR==1;NR>1{for (i=3;i<=NF;i++) print $1,$2,$i}' file

This User Gave Thanks to bartus11 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to split multiple records file in n files

Hello, Each record has a lenght of 7 characters I have 2 types of records 010 and 011 There is no character of end of line. For example my file is like that : 010hello 010bonjour011both 011sisters I would like to have 2 files 010.txt (2 records) hello bonjour and ... (1 Reply)
Discussion started by: jeuffeu
1 Replies

2. Shell Programming and Scripting

Parsing record into multiple records in Shell Script

Hi, I am trying to parse a very long record in a text file into multiple records by checking ADD, DELETE, or MODIFY field value in a shell script. Input # File name xyz.txt ADD|N000|8015662|DELETE|N001|9915662|MODIFY|N999|85678 Output ADD|N000|8015662| DELETE|N001|9915662|... (8 Replies)
Discussion started by: naveed
8 Replies

3. Shell Programming and Scripting

Multiple records based on ';' in the record

Hi All, I have a *.csv files in a die /pro/lif/dow, (pipe delimiter file), these files are having 8 columns and 6 column(CDR_LOGIC) records are populated as below, I need to incorporate the below logic in all the *.csv files. 11||:ColumnA||:ColumnB 123||:ColumnA IIF(:ColumnA = :ColumnC then... (6 Replies)
Discussion started by: shruthidwh
6 Replies

4. Shell Programming and Scripting

Split a single record to multiple records & add folder name to each line

Hi Gurus, I need to cut single record in the file(asdf) to multile records based on the number of bytes..(44 characters). So every record will have 44 characters. All the records should be in the same file..to each of these lines I need to add the folder(<date>) name. I have a dir. in which... (20 Replies)
Discussion started by: ram2581
20 Replies

5. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

6. Shell Programming and Scripting

Split records into multiple records

Hi All, I am trying to split a record into multiple records based on a value. Input.txt "A",1,0,10 "B",2,0,10,15,20 "C",3,11,14,16,19,21,23 "D",1,0,5 My desired output is: "A",1,0,10 "B",2,0,10 "B",2,15,20 "C",3,11,14 "C",3,16,19 "C",3,21,23 (4 Replies)
Discussion started by: kmsekhar
4 Replies

7. Shell Programming and Scripting

Splitting record into multiple records by appending values from an input field (AWK)

Hello, For the input file, I am trying to split those records which have multiple values seperated by '|' in the last input field, into multiple records and each record corresponds to the common input fields + one of the value from the last field. I was trying with an example on this forum... (4 Replies)
Discussion started by: imtiaz99
4 Replies

8. Shell Programming and Scripting

Multiple Records from 1 Record

I need to make one record to multiple records based on occurence column in the record and change the date.For example below first record has 5 ,so need to create 5 records from one and change the date to 5 months.Occurence can be any number. I am unable to come with a script.Can some one help ... (5 Replies)
Discussion started by: traininfa
5 Replies

9. Shell Programming and Scripting

Split a large file in n records and skip a particular record

Hello All, I have a large file, more than 50,000 lines, and I want to split it in even 5000 records. Which I can do using sed '1d;$d;' <filename> | awk 'NR%5000==1{x="F"++i;}{print > x}'Now I need to add one more condition that is not to break the file at 5000th record if the 5000th record... (20 Replies)
Discussion started by: ibmtech
20 Replies

10. Shell Programming and Scripting

How to split one record to multiple records?

Hi, I have one tab delimited file which is having multiple store_ids in first column seprated by pipe.I want to split the file on the basis of store_id(separating 1st record in to 2 records ). I tried some more options like below with using split,awk etc ,But not able to get proper output. can... (1 Reply)
Discussion started by: jaggy
1 Replies
CUBE_DISPATCHER(1)														CUBE_DISPATCHER(1)

NAME
cube_dispatcher - PgQ consumer that is used to write source records into partitoned tables SYNOPSIS
cube_dispatcher.py [switches] config.ini DESCRIPTION
cube_dispatcher is PgQ consumer that reads url encoded records from source queue and writes them into partitioned tables according to configuration file. Used to prepare data for business intelligence. Name of the table is read from producer field in event. Batch creation time is used for partitioning. All records created in same day will go into same table partion. If partiton does not exist cube dispatcer will create it according to template. Events are usually procuded by pgq.logutriga(). Logutriga adds all the data of the record into the event (also in case of updates and deletes). cube_dispatcher can be used in to modes: keep_all keeps all the data that comes in. If record is updated several times during one day then table partiton for that day will contain several instances of that record. keep_latest only last instance of each record is kept for each day. That also means that all tables must have primary keys so cube dispatcher can delete previous versions of records before inserting new data. QUICK-START Basic cube_dispatcher setup and usage can be summarized by the following steps: 1. pgq and logutriga must be installed in source databases. See pgqadm man page for details. target database must also have pgq_ext schema. 2. edit a cube_dispatcher configuration file, say cube_dispatcher_sample.ini 3. create source queue $ pgqadm.py ticker.ini create <queue> 4. create target database and parent tables in it. 5. launch cube dispatcher in daemon mode $ cube_dispatcher.py cube_dispatcher_sample.ini -d 6. start producing events (create logutriga trggers on tables) CREATE OR REPLACE TRIGGER trig_cube_replica AFTER INSERT OR UPDATE ON some_table FOR EACH ROW EXECUTE PROCEDURE pgq.logutriga(<queue>) CONFIG
Common configuration parameters job_name Name for particulat job the script does. Script will log under this name to logdb/logserver. The name is also used as default for PgQ consumer name. It should be unique. pidfile Location for pid file. If not given, script is disallowed to daemonize. logfile Location for log file. loop_delay If continuisly running process, how long to sleep after each work loop, in seconds. Default: 1. connection_lifetime Close and reconnect older database connections. log_count Number of log files to keep. Default: 3 log_size Max size for one log file. File is rotated if max size is reached. Default: 10485760 (10M) use_skylog If set, search for [./skylog.ini, ~/.skylog.ini, /etc/skylog.ini]. If found then the file is used as config file for Pythons logging module. It allows setting up fully customizable logging setup. Common PgQ consumer parameters pgq_queue_name Queue name to attach to. No default. pgq_consumer_id Consumers ID to use when registering. Default: %(job_name)s Config options specific to cube_dispatcher src_db Connect string for source database where the queue resides. dst_db Connect string for target database where the tables should be created. mode Operation mode for cube_dispatcher. Either keep_all or keep_latest. dateformat Optional parameter to specify how to suffix data tables. Default is YYYY_MM_DD which creates per-day tables. With YYYY_MM per-month tables can be created. If explicitly set empty, partitioning is disabled. part_template SQL fragment for table creation. Various magic replacements are done there: _PKEY comma separated list of primery key columns. _PARENT schema-qualified parent table name. _DEST_TABLE schema-qualified partition table. _SCHEMA_TABLE same as DEST_TABLE but dots replaced with "_", to allow use as index names. Example config file [cube_dispatcher] job_name = some_queue_to_cube src_db = dbname=sourcedb_test dst_db = dbname=dataminedb_test pgq_queue_name = udata.some_queue logfile = ~/log/%(job_name)s.log pidfile = ~/pid/%(job_name)s.pid # how many rows are kept: keep_latest, keep_all mode = keep_latest # to_char() fmt for table suffix #dateformat = YYYY_MM_DD # following disables table suffixes: #dateformat = part_template = create table _DEST_TABLE (like _PARENT); alter table only _DEST_TABLE add primary key (_PKEY); LOGUTRIGA EVENT FORMAT
PgQ trigger function pgq.logutriga() sends table change event into queue in following format: ev_type (op || ":" || pkey_fields). Where op is either "I", "U" or "D", corresponging to insert, update or delete. And pkey_fields is comma-separated list of primary key fields for table. Operation type is always present but pkey_fields list can be empty, if table has no primary keys. Example: I:col1,col2 ev_data Urlencoded record of data. It uses db-specific urlecoding where existence of = is meaningful - missing = means NULL, present = means literal value. Example: id=3&name=str&nullvalue&emptyvalue= ev_extra1 Fully qualified table name. COMMAND LINE SWITCHES
Following switches are common to all skytools.DBScript-based Python programs. -h, --help show help message and exit -q, --quiet make program silent -v, --verbose make program more verbose -d, --daemon make program go background Following switches are used to control already running process. The pidfile is read from config then signal is sent to process id specified there. -r, --reload reload config (send SIGHUP) -s, --stop stop program safely (send SIGINT) -k, --kill kill program immidiately (send SIGTERM) 03/13/2012 CUBE_DISPATCHER(1)
All times are GMT -4. The time now is 05:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy