Sponsored Content
Top Forums Shell Programming and Scripting Interchange location of words in a line of csv file Post 302681167 by viper1503 on Friday 3rd of August 2012 12:21:29 AM
Old 08-03-2012
Interchange location of words in a line of csv file

Hi,
I have a file with some info as example below. Its a csv file and i want to interchange the location of the times and dates in the 3rd and 4th fields only. I am using SunOS and csh script and would like to incorporate sed or nawk in the script (or any that would be able to accomplish this). Another important thing, My file would contain upto 200k lines ++.
Appreciate the help.

original:
Code:
Random,Words,10:12:59 12-Aug-2011,11:13:59 12-Aug-2011,Separated,By,Comma,,0,
Words,Comma,08:12:14 15-Aug-2011,05:44:48 16-Aug-2011,Random,0,Separated,By,,
Extra,Nothing,05:18:54 19-Aug-2011,14:48:23 19-Aug-2011,0,5,Change,now,,
0,Full,23:42:14 29-Aug-2011,01:23:47 30-Aug-2011,Empty,None,Random,Enclosed,,

Expected:
Code:
Random,Words,12-Aug-2011 10:12:59,12-Aug-2011 11:13:59,Separated,By,Comma,,0,
Words,Comma,15-Aug-2011 08:12:14,16-Aug-2011 05:44:48,Random,0,Separated,By,,
Extra,Nothing,19-Aug-2011 05:18:54,19-Aug-2011 14:48:23,0,5,Change,now,,
0,Full,29-Aug-2011 23:42:14,30-Aug-2011 01:23:47,Empty,None,Random,Enclosed,,

Moderator's Comments:
Mod Comment Code tags for code, please.

Last edited by Corona688; 08-03-2012 at 12:09 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Listing words from a file on a Separate Line

Hi, I want to list all the words in my file on a separate line. I am using the bourne(sh)/bourne again shell(bash). Thanks, theA (2 Replies)
Discussion started by: Astudent
2 Replies

2. Shell Programming and Scripting

Count words on each line in file using xargs

Hi, im having a problem with xargs, i want to cout word of each line in file, and i HAVE to use xargs, i tried: cat file | xargs wc -w .....that uses all words in file like name of files and passed then to wc so it worte wc :somewordformfile is not i afile or directory cat file | xargs -I{} wc... (3 Replies)
Discussion started by: Qwetek
3 Replies

3. Shell Programming and Scripting

How can i delete some words in every line in a file

Hi, I need help to delete a few words in every line in my file. This is how the file look like: VDC DQ 14900098,,,,157426.06849776753,786693.2919373367 10273032,,,,157525.49445429695,776574.5546672409 VDC DG ,10273033,,3er55,,149565.57096061576,801778.9379555212 AS174 892562,,,,, ... (2 Replies)
Discussion started by: andy_s
2 Replies

4. Shell Programming and Scripting

Copying x words from end of line to specific location in same line

Hello all i know it is pretty hard one but you will manage it all after noticing and calculating i find a rhythm for the file i want to edit to copy the last 12 characters in line but the problem is to add after first 25 characters in same line in other way too copy the last 12 characters... (10 Replies)
Discussion started by: princesasa
10 Replies

5. Red Hat

How to insert recursive words in a file on every line

Hi Guys, If someone can help me edit my script using sed or awk that will be great. I am trying to get a list of folders and their sizes upto 2 levels along with the week number by using following - (I am currently putting this information in a file and plan to run this script EVERY week) ... (1 Reply)
Discussion started by: rockf1bull
1 Replies

6. Shell Programming and Scripting

Insert text line to specific location CSV

In Perl. ***edited question below*** Hey all, I am teaching myself some simple CSV file manipulation and have become a little stuck. Say I have the following layout in the CSV file: age,name,locationIs it possible to INSERT data into the CSV into the correct age order. For example, if I had... (1 Reply)
Discussion started by: whyte_rhyno
1 Replies

7. Shell Programming and Scripting

Honey, I broke awk! (duplicate line removal in 30M line 3.7GB csv file)

I have a script that builds a database ~30 million lines, ~3.7 GB .cvs file. After multiple optimzations It takes about 62 min to bring in and parse all the files and used to take 10 min to remove duplicates until I was requested to add another column. I am using the highly optimized awk code: awk... (34 Replies)
Discussion started by: Michael Stora
34 Replies

8. Shell Programming and Scripting

Search words in multiple file line by line

Hi All I have to search servers name say like 1000+ "unique names" line by line in child.txt files in another file that is a master file where all server present say "master.txt",if child.txt's server name matches with master files then it print yes else no with server name. (4 Replies)
Discussion started by: netdbaind
4 Replies

9. Shell Programming and Scripting

Insert character at specific location in a each line of the file

Hi All, I am trying to write a shell script where it should insert character 'I' in 180th position of each line(except first and last line) of the file. Below is the script for file in /home/test/bharat/*.RET do # Process file echo "File Name=" $file #l_fileName="${file##*/}" ... (19 Replies)
Discussion started by: bharath561989
19 Replies

10. Shell Programming and Scripting

Replace particular words in file based on if finds another words in that line

Hi All, I need one help to replace particular words in file based on if finds another words in that file . i.e. my self is peter@king. i am staying at north sydney. we all are peter@king. How to replace peter to sham if it finds @king in any line of that file. Please help me... (8 Replies)
Discussion started by: Rajib Podder
8 Replies
Crypt::Random::Source::Base(3pm)			User Contributed Perl Documentation			  Crypt::Random::Source::Base(3pm)

NAME
Crypt::Random::Source::Base - Abstract base class for Crypt::Random::Source classes SYNOPSIS
use Moose; extends qw(Crypt::Random::Source::Base); DESCRIPTION
This is an abstract base class. In the future it will be a role. METHODS
get $n, %args Gets $n random bytes and returns them as a string. This method may produce fatal errors if the source was unable to provide enough data. read $buf, $n, [ $off ] This method is cannibalized from IO::Scalar. It provides an IO::Handle work-alike. Note that subclasses override this to operate on a real handle directly if available. seed @stuff On supporting sources this method will add @stuff, whatever it may be, to the random seed. Some sources may not support this, so be careful. available This is a class method, such that when it returns true calling "new" without arguments on the class should provide a working source of random data. This is use by Crypt::Random::Source::Factory. rank This is a class method, with some futz value for a ranking, to help known good sources be tried before known bad (slower, less available) sources. get_data %Params Provided for compatibility with Crypt::Random AUTHOR
Yuval Kogman <nothingmuch@woobling.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Yuval Kogman. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2011-01-05 Crypt::Random::Source::Base(3pm)
All times are GMT -4. The time now is 03:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy