Sponsored Content
Top Forums Shell Programming and Scripting How to sort columns in excel(csv) file Post 302445625 by durden_tyler on Monday 16th of August 2010 11:12:12 AM
Old 08-16-2010
Code:
$
$
$ cat f0
c3,c1,c2,c4
$
$
$ cat f1
c1,c2,c3,c4
a,b,c,d
e,f,g,h
i,j,k,l
m,n,o,p
q,r,s,t
$
$
$
$ perl -ne 'chomp; close ARGV if eof;
            if ($ARGV eq "f0") {@x = split/,/}
            elsif ($.==1) {@h = split/,/; print join(",",@x),"\n"}
            else {@d = split/,/; foreach $i(0..$#d) {$y{$h[$i]} = $d[$i]}
                  foreach $i(0..$#x) {push @p, $y{$x[$i]}}
                  print join(",",@p),"\n"; @p = ()}
           ' f0 f1
c3,c1,c2,c4
c,a,b,d
g,e,f,h
k,i,j,l
o,m,n,p
s,q,r,t
$
$

tyler_durden
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

text file to excel or csv

Hi, I have a text file like ---------------------- aaa|bbb|ccc|ddd|eee fff|gggg|hhhhhh|kkkk -------------------- I have a script which will transfer(thourgh FTP) this text file to windows system. But I want to covert it into excel or CSF then upload into windows system.. thanks (9 Replies)
Discussion started by: srikanthus2002
9 Replies

2. Shell Programming and Scripting

Perl script to sort an Excel file

Hello! I need to sort a file that is partly in English partly in Bulgarian. The original file is an Excel file but I converted it to a tab-delimited text file. The encoding of the tab delimited file is UTF-8. To sort the text, the script should test every line of the text file to see if... (9 Replies)
Discussion started by: degoor
9 Replies

3. UNIX for Dummies Questions & Answers

Excel File to CSV

Hi All, I have to convert the excel file which will be placed in the Unix box to a CSV file using a shell script. Please Advise. Thanks & Regards, Kumar66 (1 Reply)
Discussion started by: kumar66
1 Replies

4. Shell Programming and Scripting

csv file to excel issue

Hi, I am trying to attach and email a csv file in the form of an excel sheet. And I have been successful in doing this. But after some days I realised that some fields in the csv file are also having commas because of which this field is getting splitted in columns in the excel sheet. ... (5 Replies)
Discussion started by: girish1428
5 Replies

5. Shell Programming and Scripting

Sort Excel File

Hi, I am new to scripting. I have a requirement 1.convert excel 2007 format to excel 2003 fromat 2.sort the excel file -( all columns in descending order). This needs to be done progarmmatically. Please let me know what would be the possible steps that I would need to take inorder to... (2 Replies)
Discussion started by: eva13
2 Replies

6. UNIX for Advanced & Expert Users

Help in Deleting columns and Renaming Mutliple columns in a .Csv File

Hi All, i have a .Csv file in the below format startTime, endTime, delta, gName, rName, rNumber, m2239max, m2239min, m2239avg, m100016509avg, m100019240max, metric3min, m100019240avg, propValues 11-Mar-2012 00:00:00, 11-Mar-2012 00:05:00, 300.0, vma3550a, a-1_CPU Index<1>, 200237463, 0.0,... (9 Replies)
Discussion started by: mahi_mayu069
9 Replies

7. Shell Programming and Scripting

Deleting all the fields(columns) from a .csv file if all rows in that columns are blanks

Hi Friends, I have come across some files where some of the columns don not have data. Key, Data1,Data2,Data3,Data4,Data5 A,5,6,,10,, A,3,4,,3,, B,1,,4,5,, B,2,,3,4,, If we see the above data on Data5 column do not have any row got filled. So remove only that column(Here Data5) and... (4 Replies)
Discussion started by: ks_reddy
4 Replies

8. Shell Programming and Scripting

Match columns from two csv files and update field in one of the csv file

Hi, I have a file of csv data, which looks like this: file1: 1AA,LGV_PONCEY_LES_ATHEE,1,\N,1,00020460E1,0,\N,\N,\N,\N,2,00.22335321,0.00466628 2BB,LES_POUGES_ASF,\N,200,200,00006298G1,0,\N,\N,\N,\N,1,00.30887539,0.00050312... (10 Replies)
Discussion started by: djoseph
10 Replies

9. UNIX for Beginners Questions & Answers

How to sort a column in excel/csv file?

I have to sort the 4th column of an excel/csv file. I tried the following command sort -u --field-separator=, --numeric-sort -k 2 -n dinesh.csv > test.csv But, it's not working. Moreover, I have to do the same for more than 30 excel/csv file. So please help me to do the same. (6 Replies)
Discussion started by: dineshkumarsrk
6 Replies
STG-NEW(1)							   StGit Manual 							STG-NEW(1)

NAME
stg-new - Create a new, empty patch SYNOPSIS
stg new [options] [<name>] DESCRIPTION
Create a new, empty patch on the current stack. The new patch is created on top of the currently applied patches, and is made the new top of the stack. Uncommitted changes in the work tree are not included in the patch -- that is handled by linkstg:refresh[]. The given name must be unique in the stack, and may only contain alphanumeric characters, dashes and underscores. If no name is given, one is generated from the first line of the patch's commit message. An editor will be launched to edit the commit message to be used for the patch, unless the --message flag already specified one. The patchdescr.tmpl template file (if available) is used to pre-fill the editor. OPTIONS
--author "NAME <EMAIL>" Set the author details. --authname NAME Set the author name. --authemail EMAIL Set the author email. --authdate DATE Set the author date. -m MESSAGE, --message MESSAGE Use MESSAGE instead of invoking the editor. -f FILE, --file FILE Use the contents of FILE instead of invoking the editor. (If FILE is "-", write to stdout.) --save-template FILE Instead of running the command, just write the message template to FILE, and exit. (If FILE is "-", write to stdout.) When driving StGit from another program, it is often useful to first call a command with --save-template, then let the user edit the message, and then call the same command with --file. --sign Add a "Signed-off-by:" to the end of the patch. --ack Add an "Acked-by:" line to the end of the patch. STGIT
Part of the StGit suite - see linkman:stg[1] StGit 03/13/2012 STG-NEW(1)
All times are GMT -4. The time now is 07:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy