Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Creating a two column list of date pairs form a single column list Post 302843704 by jbrandt1979 on Wednesday 14th of August 2013 01:22:00 PM
Old 08-14-2013
Creating a two column list of date pairs form a single column list

Hi all, looking for some help here. I'm what you'd call a dirty programmer. my shell scripts might be ugly, but they (usually) function...

Say I have a single column text file with a list of dates (yyyymmdd) that represent the elevation of a point on that date (I work with land subsidence, so the elevation changes thru time):

Code:
date1
date2
date3
date4
...
date-n

I want to then create another two column text file that contains a list of all possible date combinations, so I can then figure out the change in elevation between two time periods. I need to create this text file for input into another software I use.

Code:
date1  date2
date1  date3
...
date1  date-n
date2  date3
date2  date4
...
date2  date-n
date3  date4
...
date-n-1 date-n

Any ideas?

Thanks all!
JB

Last edited by Scott; 08-14-2013 at 04:16 PM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sorting list of files per date column

Hi all, I have a pecular issue in sorting these files (not an ls -lrt) in Solaris environment. All the below files are modified on November 4th, but I want to sort these files as per date (eg: 01May07_1623 = ddmmmyy_hhmm) Nov 4 18:27 SONYELEC00.GI22973.01May07_1623.gpg Nov 4 18:27... (10 Replies)
Discussion started by: shivaastrogun
10 Replies

2. Shell Programming and Scripting

paste each 10 lines of single column to several column

Hi, I need to paste each 10 lines of single column to several columns. Please, can anyone tell me how to write in awk? Input File: 22 34 36 12 17 19 15 11 89 99 56 38 29 (4 Replies)
Discussion started by: nica
4 Replies

3. UNIX for Dummies Questions & Answers

creating a file using the fist column and printing second column

Hello all. I have a problem that I need help solving. I would like to convert the following file: human pool1_12 10e-02 45 67 human pool1_1899 10e-01 45 29 human pool1_1829 10e-01 43 26 horse pool1_343 10e-20 65 191 horse pool1_454 10e-09 44 43... (5 Replies)
Discussion started by: viralnerd
5 Replies

4. UNIX for Advanced & Expert Users

need to get single column form csv file

hi 2 all i need to get single column from one csv file anyone help me ! >cat file.csv name,age x,1 y,2 z,3 Use code tags please, ty. in this "file.csv" file i need only name column can u help me !:b::b: (7 Replies)
Discussion started by: ponmuthu
7 Replies

5. Shell Programming and Scripting

Construct 3 column table from one column list

Hi all! trying my best to parse a public site for information (ie fiscal year and turnover) about corporations. Doing this by having a file with business name and registration number (search key) the file bolag.txt currently looks like this Burgundy 556732-7217 AcademicSearch 556406-9879... (11 Replies)
Discussion started by: martindebruin
11 Replies

6. UNIX for Dummies Questions & Answers

Creating a column based list from a string list

I have a string containing fields separated by space Example set sr="Fred Ted Joe Peter Paul Jean Chris Tim Tex" and want to display it in a column format, for example to a maximum of a window of 100 characters And hopefully display some thing like Fred Ted Joe ... (3 Replies)
Discussion started by: kristinu
3 Replies

7. UNIX for Dummies Questions & Answers

List several files into one single column

frtgyh (2 Replies)
Discussion started by: lucasvs
2 Replies

8. Shell Programming and Scripting

Converting Single Column into Multiple rows, but with strings to specific tab column

Dear fellows, I need your help. I'm trying to write a script to convert a single column into multiple rows. But it need to recognize the beginning of the string and set it to its specific Column number. Each Line (loop) begins with digit (RANGE). At this moment it's kind of working, but it... (6 Replies)
Discussion started by: AK47
6 Replies

9. Shell Programming and Scripting

Bring values in the second column into single line (comma sep) for uniq value in the first column

I want to bring values in the second column into single line for uniq value in the first column. My input jvm01, Web 2.0 Feature Pack Library jvm01, IBM WebSphere JAX-RS jvm01, Custom01 Shared Library jvm02, Web 2.0 Feature Pack Library jvm02, IBM WebSphere JAX-RS jvm03, Web 2.0 Feature... (10 Replies)
Discussion started by: kchinnam
10 Replies

10. Shell Programming and Scripting

Get maximum per column from CSV file, based on date column

Hello everyone, I am using ksh on Solaris 10 and I'm gathering data in a CSV file that looks like this: 20170628-23:25:01,1,0,0,1,1,1,1,55,55,1 20170628-23:30:01,1,0,0,1,1,1,1,56,56,1 20170628-23:35:00,1,0,0,1,1,2,1,57,57,2 20170628-23:40:00,1,0,0,1,1,1,1,58,58,2... (6 Replies)
Discussion started by: ejianu
6 Replies
DateTime::Span(3pm)					User Contributed Perl Documentation				       DateTime::Span(3pm)

NAME
DateTime::Span - Datetime spans SYNOPSIS
use DateTime; use DateTime::Span; $date1 = DateTime->new( year => 2002, month => 3, day => 11 ); $date2 = DateTime->new( year => 2003, month => 4, day => 12 ); $set2 = DateTime::Span->from_datetimes( start => $date1, end => $date2 ); # set2 = 2002-03-11 until 2003-04-12 $set = $set1->union( $set2 ); # like "OR", "insert", "both" $set = $set1->complement( $set2 ); # like "delete", "remove" $set = $set1->intersection( $set2 ); # like "AND", "while" $set = $set1->complement; # like "NOT", "negate", "invert" if ( $set1->intersects( $set2 ) ) { ... # like "touches", "interferes" if ( $set1->contains( $set2 ) ) { ... # like "is-fully-inside" # data extraction $date = $set1->start; # first date of the span $date = $set1->end; # last date of the span DESCRIPTION
"DateTime::Span" is a module for handling datetime spans, otherwise known as ranges or periods ("from X to Y, inclusive of all datetimes in between"). This is different from a "DateTime::Set", which is made of individual datetime points as opposed to a range. There is also a module "DateTime::SpanSet" to handle sets of spans. METHODS
o from_datetimes Creates a new span based on a starting and ending datetime. A 'closed' span includes its end-dates: $span = DateTime::Span->from_datetimes( start => $dt1, end => $dt2 ); An 'open' span does not include its end-dates: $span = DateTime::Span->from_datetimes( after => $dt1, before => $dt2 ); A 'semi-open' span includes one of its end-dates: $span = DateTime::Span->from_datetimes( start => $dt1, before => $dt2 ); $span = DateTime::Span->from_datetimes( after => $dt1, end => $dt2 ); A span might have just a beginning date, or just an ending date. These spans end, or start, in an imaginary 'forever' date: $span = DateTime::Span->from_datetimes( start => $dt1 ); $span = DateTime::Span->from_datetimes( end => $dt2 ); $span = DateTime::Span->from_datetimes( after => $dt1 ); $span = DateTime::Span->from_datetimes( before => $dt2 ); You cannot give both a "start" and "after" argument, nor can you give both an "end" and "before" argument. Either of these conditions will cause the "from_datetimes()" method to die. To summarize, a datetime passed as either "start" or "end" is included in the span. A datetime passed as either "after" or "before" is excluded from the span. o from_datetime_and_duration Creates a new span. $span = DateTime::Span->from_datetime_and_duration( start => $dt1, duration => $dt_dur1 ); $span = DateTime::Span->from_datetime_and_duration( after => $dt1, hours => 12 ); The new "end of the set" is open by default. o clone This object method returns a replica of the given object. o set_time_zone( $tz ) This method accepts either a time zone object or a string that can be passed as the "name" parameter to "DateTime::TimeZone->new()". If the new time zone's offset is different from the old time zone, then the local time is adjusted accordingly. If the old time zone was a floating time zone, then no adjustments to the local time are made, except to account for leap seconds. If the new time zone is floating, then the UTC time is adjusted in order to leave the local time untouched. o duration The total size of the set, as a "DateTime::Duration" object, or as a scalar containing infinity. Also available as "size()". o start o end First or last dates in the span. It is possible that the return value from these methods may be a "DateTime::Infinite::Future" or a "DateTime::Infinite::Past"xs object. If the set ends "before" a date $dt, it returns $dt. Note that in this case $dt is not a set element - but it is a set boundary. o start_is_closed o end_is_closed Returns true if the first or last dates belong to the span ( begin <= x <= end ). o start_is_open o end_is_open Returns true if the first or last dates are excluded from the span ( begin < x < end ). o union o intersection o complement Set operations may be performed not only with "DateTime::Span" objects, but also with "DateTime::Set" and "DateTime::SpanSet" objects. These set operations always return a "DateTime::SpanSet" object. $set = $span->union( $set2 ); # like "OR", "insert", "both" $set = $span->complement( $set2 ); # like "delete", "remove" $set = $span->intersection( $set2 ); # like "AND", "while" $set = $span->complement; # like "NOT", "negate", "invert" o intersects o contains These set functions return a boolean value. if ( $span->intersects( $set2 ) ) { ... # like "touches", "interferes" if ( $span->contains( $dt ) ) { ... # like "is-fully-inside" These methods can accept a "DateTime", "DateTime::Set", "DateTime::Span", or "DateTime::SpanSet" object as an argument. SUPPORT
Support is offered through the "datetime@perl.org" mailing list. Please report bugs using rt.cpan.org AUTHOR
Flavio Soibelmann Glock <fglock@gmail.com> The API was developed together with Dave Rolsky and the DateTime Community. COPYRIGHT
Copyright (c) 2003-2006 Flavio Soibelmann Glock. All rights reserved. This program is free software; you can distribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. SEE ALSO
Set::Infinite For details on the Perl DateTime Suite project please see <http://datetime.perl.org>. perl v5.12.4 2011-08-22 DateTime::Span(3pm)
All times are GMT -4. The time now is 05:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy