Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How convert space separated list to matched columns? Post 302830539 by Manchesterpaul on Tuesday 9th of July 2013 05:20:24 AM
Old 07-09-2013
How convert space separated list to matched columns?

Hi
I have been racking my (limited) brains to get this to work without success

I have a file output which is a list of lists - ie a single column of data that is separated by space into sub lists below - I need to both split this so that each list is in a separate column (eg tab or semicolon separated) but then also I need to match up the rows in each column. The data looks like this but with about 2000 sub-lists:

AF10_identified_SNPs.vcf:
Code:
CADAFUAG00000594,53,240575,G,A
CADAFUAG00000594,53,242762,A,G
CADAFUAG00000594,53,243450,T,G
CADAFUAG00003722,94,896971,T,C
CADAFUAG00003722,94,898802,A,C
CADAFUAG00003979,102,144910,A,C
CADAFUAG00003979,102,145332,C,T
CADAFUAG00003979,102,145623,T,C
CADAFUAG00004144,93,1548479,A,G
CADAFUAG00004144,93,1548862,T,C
CADAFUAG00004144,93,1548899,T,A
CADAFUAG00004144,93,1549237,A,G
CADAFUAG00004144,93,1549256,G,A
CADAFUAG00004225,101,81335,T,C

AF1163_identified_SNPs.vcf:
Code:
CADAFUAG00000594,53,240575,G,A
CADAFUAG00000594,53,242762,A,G
CADAFUAG00000594,53,243450,T,G
CADAFUAG00003722,94,898802,A,C
CADAFUAG00003979,102,145628,C,T
CADAFUAG00004144,93,1548335,G,A
CADAFUAG00004144,93,1548479,A,G
CADAFUAG00004144,93,1548862,T,C
CADAFUAG00004144,93,1548899,T,A
CADAFUAG00004144,93,1549237,A,G
CADAFUAG00004144,93,1549256,G,A
CADAFUAG00004225,101,81335,T,C

AF210_identified_SNPs.vcf:
Code:
CADAFUAG00000594,53,239935,A,T
CADAFUAG00000594,53,240575,G,A
CADAFUAG00000594,53,241319,C,T
CADAFUAG00000594,53,242762,A,G
CADAFUAG00000594,53,243450,T,G
CADAFUAG00003722,94,897525,G,A
CADAFUAG00003979,102,145623,T,C
CADAFUAG00004144,93,1548479,A,G
CADAFUAG00004144,93,1548658,T,G
CADAFUAG00004144,93,1548862,T,C
CADAFUAG00004144,93,1548899,T,A
CADAFUAG00004144,93,1549256,G,A
CADAFUAG00004144,93,1549271,C,A
CADAFUAG00005594,100,552059,T,C

any help would be much appreciated
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert from CSV to space padded columns (.ksh)

Hello, Could someone please help me to convert a string(s) of comma separated values into space padded columns in .ksh? ex. 10-21-2008,someword,blah,127.0.0.1,8,3 10-21-2008,randomword,ick,128.0.111.128,1,0 converted to 10-21-2008 someword blah 127.0.0.1 8... (6 Replies)
Discussion started by: WhotheWhat
6 Replies

2. Shell Programming and Scripting

how to convert a line to columns, separated by | (pipe)

Hi, Plz help. input line 1;20100403;400|2;20100403;4|3;20290903;400|4;20290903;0|5;20290903;0|9;20100304;0|10;20100304;0|11;20100402;0|18;20100304;0 expected output 1;20100403;400 2;20100403;4 3;20290903;400 4;20290903;0 5;20290903;0 9;20100304;0 10;20100304;0 11;20100402;0... (4 Replies)
Discussion started by: suresh3566
4 Replies

3. Shell Programming and Scripting

Convert a tab separated file using bash

Dear all, I have a file in this format (like a matrix) - A B C .. X A 1 4 2 .. 2 B 2 6 4 .. 8 C 3 5 5 .. 4 . . . ... . X . . ... . and want to convert it into a file with this format: A A = 1 A B = 4 A C = 2 ... A X = 2 B A = 2 B B = 6 etc (2 Replies)
Discussion started by: TheTransporter
2 Replies

4. Shell Programming and Scripting

How to loop through space separated values?

How do I loop thru space separated values in a variable? I hate to use very complicated counter increment logic for this kind of simple problem. Expected result(using ksh) $>echo "aaa bbbb cccc" | <looping code here> var=aaa var=bbbb var=cccc $>echo "aaa bbbb cccc" | while IFS=" "... (12 Replies)
Discussion started by: kchinnam
12 Replies

5. UNIX for Dummies Questions & Answers

[solved] Comma separated values to space separated

Hi, I have a large number of files which are written as csv (comma-separated values). Does anyone know of simple sed/awk command do achieve this? Thanks! ---------- Post updated at 10:59 AM ---------- Previous update was at 10:54 AM ---------- Guess I asked this too soon. Found the... (0 Replies)
Discussion started by: lost.identity
0 Replies

6. Shell Programming and Scripting

Convert comma separated file to fix length

Hi, I am converting a comma separated file to fixed field lenght and I am using that: COLUMNS="25 24 67 26 39 63 20 34 35 14 397" ( cat $indir/input_file.dat | \ $AWK -v columns="$COLUMNS" ' BEGIN { FS=","; OFS=""; split(columns, arr, " "); } { for(i=1; i<=NF;... (5 Replies)
Discussion started by: apenkov
5 Replies

7. Shell Programming and Scripting

Matched a pattern from multiple columns

Hi, I need to extract an info in $1 based on a matched pattern in $2,$3,$4, and $5. The sample input file as follows:- ID Pat1 Pat2 Pro1 use1 add41 M M M add87 M M M M add32 ... (16 Replies)
Discussion started by: redse171
16 Replies

8. Shell Programming and Scripting

Need Help on For Loop to pass space separated value as one value

Hi, I am having a file say list1 with a output like below jun 12 18:23 may 20 18:23 Now i want to pass the above two values into for loop,I have written a script like this. #!/bin/bash a=`cat list1` for i in $a do echo "HI $i" done expected output: HI jun 12 18:23 (3 Replies)
Discussion started by: sumanthupar
3 Replies

9. Shell Programming and Scripting

Convert column to quote and comma separated row

Hi, I have a list of tables in a file.txt C_CLAIM C_HLD C_PROVIDER I want the output to be 'C_CLAIM','C_HLD','C_PROVIDER' Currently I'm usin awk and getting output which is almost correct but still has minor defects awk -vORS="','" '{ print $1 }' file.txt The output of... (4 Replies)
Discussion started by: wahi80
4 Replies

10. Shell Programming and Scripting

Convert fixed value fields to comma separated values

Hi All, Hope you are doing Great!!!. Today i have came up with a problem to say exactly it was for performance improvement. I have written code in perl as a solution for this to cut in specific range, but it is taking time to run for files thousands of lines so i am expecting a sed... (9 Replies)
Discussion started by: mad man
9 Replies
DateTime::Format::Epoch::Unix(3pm)			User Contributed Perl Documentation			DateTime::Format::Epoch::Unix(3pm)

NAME
DateTime::Format::Epoch::Unix - Convert DateTimes to/from Unix epoch seconds SYNOPSIS
use DateTime::Format::Epoch::Unix; my $dt = DateTime::Format::Epoch::Unix->parse_datetime( 1051488000 ); # 2003-04-28T00:00:00 DateTime::Format::Epoch::Unix->format_datetime($dt); # 1051488000 my $formatter = DateTime::Format::Epoch::Unix->new(); my $dt2 = $formatter->parse_datetime( 1051488000 ); $formatter->format_datetime($dt2); DESCRIPTION
This module can convert a DateTime object (or any object that can be converted to a DateTime object) to the number of seconds since the Unix epoch. METHODS
Most of the methods are the same as those in DateTime::Format::Epoch. The only difference is the constructor. o new() Constructor of the formatter/parser object. It has no parameters. SUPPORT
Support for this module is provided via the datetime@perl.org email list. See http://lists.perl.org/ for more details. AUTHOR
Eugene van der Pijll <pijll@gmx.net> COPYRIGHT
Copyright (c) 2003 Eugene van der Pijll. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
DateTime datetime@perl.org mailing list perl v5.10.1 2007-12-03 DateTime::Format::Epoch::Unix(3pm)
All times are GMT -4. The time now is 11:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy