Sponsored Content
Top Forums UNIX for Advanced & Expert Users Insert records in a file columnwise Post 302300486 by abhijeet1409 on Tuesday 24th of March 2009 09:05:57 AM
Old 03-24-2009
Bug Insert records in a file columnwise

Hello everyone!!!!! Need some help on inserting data in a file columnwise.

Example:
File1:
1|AAA|25|2
5|qqe|20|7
4|wer|31|81

I need to create a second file in which data can be inserted in a columnwise manner i.e.
File2:
AAA|25|1|2
qqe|20|5|7
wer|31|4|81

The order of columns in file1 and file2 need not be same as illustrated in the example. Lets say, I need to pick up column2 of file1 and it should be column1 in file2 and so on..
Could you please suggest how do I go about it?

The mapping of columns is done dyanamically...i.e. assigning the column to be mapped to a variable by reading it from a mapping file
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

rearranging the data in file (from columnwise to rowwise)

Hi I have one file which is having data like 10201 10202 10205 10206 10207 10208 10209 10210 10211 10213 10215 10801 10802 11406 11415 11422 11426 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11530 11604 11608 11611 11717 11718 11719 11722 11725... (3 Replies)
Discussion started by: reldb
3 Replies

2. UNIX for Advanced & Expert Users

unix script for update or insert records from a file to a oracle table

Hi, I have delimited file(|). Sample data: 1|name|50009|DS24|0|12 2|name|30009|DS24|0|13 3|name|20409|DS24|0|14 4|name|20009|DS24|0|15 5|name|10009|DS24|0|16 I want to load this data into a oracle table (update and insert) Please help me the commands and also... (1 Reply)
Discussion started by: unihp1
1 Replies

3. Shell Programming and Scripting

Comparing files columnwise and print the differences in third file

Hello Everybody!!!!!!!!! Request you to help me with the below mentioned issue: I have 2 files say, File 1: a|4|7 b|3|2 c|8|8 d|8|9 File 2: a|4|6 b|2|2 c|8|8 d|9|8 The third file(output file) should have: Data mismatch in row 1 column 3 Data mismatch in row 2 coumn 2 Data... (3 Replies)
Discussion started by: abhijeet1409
3 Replies

4. Shell Programming and Scripting

Insert records in a file columnwise

Hello everyone!!!!! Need some help on inserting data in a file columnwise. Example: File1: 1|AAA|25|2 5|qqe|20|7 4|wer|31|81 I need to create a second file in which data can be inserted in a columnwise manner i.e. File2: AAA|25|1|2 qqe|20|5|7 wer|31|4|81 The order of columns in... (1 Reply)
Discussion started by: abhijeet1409
1 Replies

5. Shell Programming and Scripting

Parse a File ColumnWise & Delete the Rows

Hi , I have a CSV file that has around 50K records in it. I have to delete all the duplicate rows from the file except one, depending upon data in column4. Lets say there are 3 rows for 'column4data' in the file. I have to retain only that line which has the smallest date value in column2.... (3 Replies)
Discussion started by: Sheel
3 Replies

6. Shell Programming and Scripting

how to Insert values in multiple lines(records) within a pipe delimited text file in specific cols

this is Korn shell unix. The scenario is I have a pipe delimited text file which needs to be customized. say for example,I have a pipe delimited text file with 15 columns(| delimited) and 200 rows. currently the 11th and 12th column has null values for all the records(there are other null columns... (4 Replies)
Discussion started by: vasan2815
4 Replies

7. Shell Programming and Scripting

Trim a file columnwise

Hi All, I want to trim each columns leading & trailing (like sql trim function) of a ',' separated file.. I've a file like this.. manab , c gi lucky , home babu , maa I want the output as manab,c gi lucky,home babu,maa A one liner would be a great help. (2 Replies)
Discussion started by: manab86
2 Replies

8. Shell Programming and Scripting

File comparison in UNIX columnwise

Hi all, I want to compare two files with same number of rows and columns with records in same order. Just want to highlight the differences in the column values if any. file A 1,kolkata,19,ab 2,delhi,89,cd 3,bangalore,56,ef file2: 1,kolkata,21,ab 2,mumbai,89,gh 3,bangalore,11,kl... (9 Replies)
Discussion started by: prabhat.diwaker
9 Replies

9. UNIX for Dummies Questions & Answers

Reading Xml file and print the values into the text file in columnwise?

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (4 Replies)
Discussion started by: sravanreddy
4 Replies

10. UNIX for Beginners Questions & Answers

1. This will insert the records into db table by reading from ta csv file

I have this code with me but the condition is If any of the mandatory columns are null then entire file will be rejected. LOAD DATA infile ' ' #specifies the name of a datafile containing data that you want to load BADFILE ' ' #specifies the name of... (1 Reply)
Discussion started by: raka123
1 Replies
INSERT(7)							   SQL Commands 							 INSERT(7)

NAME
INSERT - create new rows in a table SYNOPSIS
INSERT INTO table [ ( column [, ...] ) ] { DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) | SELECT query } INPUTS table The name (optionally schema-qualified) of an existing table. column The name of a column in table. DEFAULT VALUES All columns will be filled by null values or by values specified when the table was created using DEFAULT clauses. expression A valid expression or value to assign to column. DEFAULT This column will be filled in by the column DEFAULT clause, or NULL if a default is not available. query A valid query. Refer to the SELECT statement for a further description of valid arguments. OUTPUTS INSERT oid 1 Message returned if only one row was inserted. oid is the numeric OID of the inserted row. INSERT 0 # Message returned if more than one rows were inserted. # is the number of rows inserted. DESCRIPTION
INSERT allows one to insert new rows into a table. One can insert a single row at a time or several rows as a result of a query. The col- umns in the target list may be listed in any order. Each column not present in the target list will be inserted using a default value, either a declared DEFAULT value or NULL. PostgreSQL will reject the new column if a NULL is inserted into a column declared NOT NULL. If the expression for each column is not of the correct data type, automatic type coercion will be attempted. You must have insert privilege to a table in order to append to it, as well as select privilege on any table specified in a WHERE clause. USAGE
Insert a single row into table films: INSERT INTO films VALUES ('UA502','Bananas',105,'1971-07-13','Comedy',INTERVAL '82 minute'); In this second example the last column len is omitted and therefore it will have the default value of NULL: INSERT INTO films (code, title, did, date_prod, kind) VALUES ('T_601', 'Yojimbo', 106, DATE '1961-06-16', 'Drama'); In the third example, we use the DEFAULT values for the date columns rather than specifying an entry. INSERT INTO films VALUES ('UA502','Bananas',105,DEFAULT,'Comedy',INTERVAL '82 minute'); INSERT INTO films (code, title, did, date_prod, kind) VALUES ('T_601', 'Yojimbo', 106, DEFAULT, 'Drama'); Insert a single row into table distributors; note that only column name is specified, so the omitted column did will be assigned its default value: INSERT INTO distributors (name) VALUES ('British Lion'); Insert several rows into table films from table tmp: INSERT INTO films SELECT * FROM tmp; Insert into arrays (refer to the PostgreSQL User's Guide for further information about arrays): -- Create an empty 3x3 gameboard for noughts-and-crosses -- (all of these queries create the same board attribute) INSERT INTO tictactoe (game, board[1:3][1:3]) VALUES (1,'{{"","",""},{},{"",""}}'); INSERT INTO tictactoe (game, board[3][3]) VALUES (2,'{}'); INSERT INTO tictactoe (game, board) VALUES (3,'{{,,},{,,},{,,}}'); COMPATIBILITY
SQL92 INSERT is fully compatible with SQL92. Possible limitations in features of the query clause are documented for SELECT [select(7)]. SQL - Language Statements 2002-11-22 INSERT(7)
All times are GMT -4. The time now is 11:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy