Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to Dump data into CSV file which is Separate by <tab>? Post 303032616 by Don Cragun on Thursday 21st of March 2019 04:18:36 AM
Old 03-21-2019
In case your column count isn't always two or the row count isn't the same in all columns, you could also try:
Code:
awk '
BEGIN {	ncol = row = 0
}
/^$/ {	ncol++
	if(row > maxrow)
		maxrow = row
	row = 0
	next
}
{	d[row++, ncol] = $0
}
END {	if(row > maxrow)
		maxrow = row
	for(row = 0; row < maxrow; row++)
		for(col = 0; col <= ncol; col++)
			printf("%s%s", d[row, col],
			    (col == ncol) ? "\n" : "\t")
}' file

which with your sample input file produces the output:
Code:
ABC	XYZ
PQR	ASD

And, if given an input file that contains:
Code:
ABC
PQR
c0r2

XYZ
ASD
c1r2
c1r3

c2r0
c2r1
c2r2
c2r3
c2r4

produces the output:
Code:
ABC	XYZ	c2r0
PQR	ASD	c2r1
c0r2	c1r2	c2r2
	c1r3	c2r3
		c2r4

If someone else wants to try this on a Solaris/SunOS system, change awk in the code above to /usr/xpg4/bin/awk or nawk.
These 2 Users Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to create a CSV File by reading fields from separate files

SHELL SCRIPT Hi, I have 3 separate files within a folder. Every File contains data in a single column like File1 contains data mayank sushant dheeraj File2 contains DSA_AT MG_AT FLAT_09 File3 contains data 123123 232323 (2 Replies)
Discussion started by: mayanksargoch
2 Replies

2. Shell Programming and Scripting

Shell script - Excel/CSV file - More than one tab

Hi All, Following is my requirement. I have searched the site and found some threads which has same queries, but non of them have any answer. I thought of posting it once more. We are generating different reports through shell script after we finish our data load. Currently there are 7 such... (5 Replies)
Discussion started by: ace_friends22
5 Replies

3. Shell Programming and Scripting

Conversion of xhtml data into csv format using dump utility

Hi Unix Gurus, I tried to convert the attached xhtml table content into csv file using unix shell script (lynx -dump filename) and got the below results: Title ID Owner Priority Estimate Project Change Date Changed By Complexity Create Date Created By Detail Estimate Total De tail... (6 Replies)
Discussion started by: bi.infa
6 Replies

4. UNIX for Dummies Questions & Answers

using sed delete a line from csv file based on specific data in two separate fields

Hello, :wall: I have a 12 column csv file. I wish to delete the entire line if column 7 = hello and column 12 = goodbye. I have tried everything that I can find in all of my ref books. I know this does not work /^*,*,*,*,*,*,"hello",*,*,*,*,"goodbye"/d Any ideas? Thanks Please... (2 Replies)
Discussion started by: Chris Eagleson
2 Replies

5. Shell Programming and Scripting

How to add a new sheet or a new tab in a csv file?

Hi All, I woulk like thanks to all of you for your instant support. I am again in a trouble so move to here for solution. I want to add a new sheet or a new tab in a csv file means a singly csv file having two or more sheets. Please help me any help towards this should highly be appreciated. ... (3 Replies)
Discussion started by: Ashish Singhal
3 Replies

6. Shell Programming and Scripting

Csv file separate using awk

Hi, I have file like below apple,orange,pineapple,pappya,guva,avocado want to store as apple orange pineapple pappya I tried below command to seprate first field command1: (3 Replies)
Discussion started by: stew
3 Replies

7. UNIX for Dummies Questions & Answers

Writing multiple outputs in to separate cells of CSV file

Hi I am writing a script which has multiple awk statements and each statement gives me a numeric count as an output. I want those output to be stored in different cells of a csv file. say 12 awk statements give 12 output and i want them in diffrenet cells of csv file. Thank you guys..!! (4 Replies)
Discussion started by: prabhat.diwaker
4 Replies

8. Shell Programming and Scripting

How to convert space&tab delimited file to CSV?

Hello, I have a text file with space and tab (mixed) delimited file and need to convert into CSV. # cat test.txt /dev/rmt/tsmmt32 HP Ultrium 6-SCSI J3LZ 50:03:08:c0:02:72:c0:b5 F00272C0B5 0/0/6/1/1.145.17.255.0.0.0 /dev/rmt/c102t0d0BEST /dev/rmt/tsmmt37 ... (6 Replies)
Discussion started by: prvnrk
6 Replies

9. Shell Programming and Scripting

Compare 2 files of csv file and match column data and create a new csv file of them

Hi, I am newbie in shell script. I need your help to solve my problem. Firstly, I have 2 files of csv and i want to compare of the contents then the output will be written in a new csv file. File1: SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0713.JPG,2015:02:17 11:14:07... (8 Replies)
Discussion started by: refrain
8 Replies

10. Shell Programming and Scripting

How to separate data coming in one column of CSV file?

I am running an ISQL command on Sybase DB and getting output of a query in an CSV file. The issue is that all the data comes in to the same column, i want them to be separated in different columns. SQL_COMMAND=command.sql file=file.txt formatFile=formatFile.txt report=report.csv echo... (1 Reply)
Discussion started by: Sharma331
1 Replies
TOKENS(1)						       AFS Command Reference							 TOKENS(1)

NAME
tokens, tokens.krb - Displays the issuer's tokens SYNOPSIS
tokens [-help] tokens [-h] tokens.krb [-help] tokens.krb [-h] DESCRIPTION
The tokens command displays all tokens (tickets) cached on the local machine for the issuer. AFS server processes require that their clients present a token as evidence that they have authenticated in the server's local cell. The (mostly obsolete) tokens.krb command is the same as tokens except that it also displays the user's Kerberos v4 ticket cache. OPTIONS
-help Prints the online help for this command. All other valid options are ignored. OUTPUT
The output lists one token for each cell in which the user is authenticated. The output indicates the o User's AFS UID, if it is available for display. o Server for which the token is valid (normally, afs). This includes a cell specification. o Day and time the token expires. The output of the Kerberos version of this command, tokens.krb, also reports the following about the Kerberos ticket-granting ticket: the ticket owner, which Kerberos ticket-granting service that issued the ticket (for example, "krbtgt.ABC.COM"), and ticket's expiration date. The string "--End of list--" appears at the end of the output. If the user is not authenticated in any cell, this line is all that appears. EXAMPLES
The following example shows the output when the issuer is not authenticated in any cell. % tokens Tokens held by the Cache Manager: --End of list-- The following example shows the output when the issuer is authenticated in ABC Corporation cell, where he or she has AFS UID 1000. % tokens Tokens held by the Cache Manager: User's (AFS ID 1000) tokens for afs@abc.com [Expires Jan 2 10:00] --End of list-- The following example shows the output when the issuer is authenticated in the ABC Corporation cell, the State University cell, and the XYZ Company cell. The user has different AFS UIDs in the three cells. Tokens for last cell are expired: % tokens Tokens held by the Cache Manager: User's (AFS ID 1000) tokens for afs@abc.com [Expires Jan 3 10:00] User's (AFS ID 4286) tokens for afs@stateu.edu [Expires Jan 3 1:34] User's (AFS ID 22) tokens for afs@xyz.com [>>Expired<] --End of list-- The following example shows the output when the issuer uses the tokens.krb version of the command after authenticating in the ABC Corporation cell using the klog.krb command. % tokens.krb Tokens held by the Cache Manager: User's (AFS ID 1000) tokens for afs@abc.com [Expires Jan 31 00:09] User smiths tokens for krbtgt.ABC.COM@abc.com [Expires Jan 31 00:09] --End of list-- PRIVILEGE REQUIRED
None SEE ALSO
klog(1), unlog(1) COPYRIGHT
IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved. This documentation is covered by the IBM Public License Version 1.0. It was converted from HTML to POD by software written by Chas Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell. OpenAFS 2012-03-26 TOKENS(1)
All times are GMT -4. The time now is 01:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy