Merging 2 files with different timestamp

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Merging 2 files with different timestamp

Bhaskar Mitra
Hello, I am trying to merge two text files by using the timestamp
header for both the files:

The first file has the following format for the timestamp:"2012-01-01
23:30:00 UTC"

Timestamp for the second file : 2012-01-01 2330.

I am having problems by converting from one timestamp format to another.
Any suggestions/help in this regard?

regards,

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Merging 2 files with different timestamp

Bhaskar Mitra
Hello,

My apologies for the earlier posting. There was an error with regard to my
query :


I am trying to merge two text files by using the timestamp
header for both the files:

The first file has the following format for the timestamp:"27-Dec-12 23H
30M 0S"

Timestamp for the second file : 2012-12-27 2330.

I am having problems by converting from one timestamp format to another.
Any suggestions/help in this regard?

regards,




On Sun, May 22, 2016 at 12:40 PM, Bhaskar Mitra <[hidden email]>
wrote:

> Hello, I am trying to merge two text files by using the timestamp
> header for both the files:
>
> The first file has the following format for the timestamp:"2012-01-01
> 23:30:00 UTC"
>
> Timestamp for the second file : 2012-01-01 2330.
>
> I am having problems by converting from one timestamp format to another.
> Any suggestions/help in this regard?
>
> regards,
>
>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Merging 2 files with different timestamp

Jeff Newmiller
What time zone are these data in? Does daylight savings adjustment apply?
--
Sent from my phone. Please excuse my brevity.

On May 22, 2016 9:48:08 AM PDT, Bhaskar Mitra <[hidden email]> wrote:

>Hello,
>
>My apologies for the earlier posting. There was an error with regard to
>my
>query :
>
>
>I am trying to merge two text files by using the timestamp
>header for both the files:
>
>The first file has the following format for the timestamp:"27-Dec-12
>23H
>30M 0S"
>
>Timestamp for the second file : 2012-12-27 2330.
>
>I am having problems by converting from one timestamp format to
>another.
>Any suggestions/help in this regard?
>
>regards,
>
>
>
>
>On Sun, May 22, 2016 at 12:40 PM, Bhaskar Mitra
><[hidden email]>
>wrote:
>
>> Hello, I am trying to merge two text files by using the timestamp
>> header for both the files:
>>
>> The first file has the following format for the timestamp:"2012-01-01
>> 23:30:00 UTC"
>>
>> Timestamp for the second file : 2012-01-01 2330.
>>
>> I am having problems by converting from one timestamp format to
>another.
>> Any suggestions/help in this regard?
>>
>> regards,
>>
>>
>>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Merging 2 files with different timestamp

jholtman
In reply to this post by Bhaskar Mitra
Is this the format of a column within the two different files?  If they are
columns, here is a way of converting to a common format for merging:


> # convert to POSIXct
> date1 <- as.POSIXct("27-Dec-12 23H 30M 0S", format = "%d-%b-%y %HH %MM
%SS")
> date2 <- as.POSIXct('2012-12-27 2330', format = "%Y-%m-%d %H%M")
>
> # now convert to a common character format for merging
> date1_new <- format(date1, "%Y%m%d%H%M%S")
> date2_new <- format(date2, "%Y%m%d%H%M%S")
> date1_new
[1] "20121227233000"
> date2_new
[1] "20121227233000"



Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Sun, May 22, 2016 at 12:48 PM, Bhaskar Mitra <[hidden email]>
wrote:

> Hello,
>
> My apologies for the earlier posting. There was an error with regard to my
> query :
>
>
> I am trying to merge two text files by using the timestamp
> header for both the files:
>
> The first file has the following format for the timestamp:"27-Dec-12 23H
> 30M 0S"
>
> Timestamp for the second file : 2012-12-27 2330.
>
> I am having problems by converting from one timestamp format to another.
> Any suggestions/help in this regard?
>
> regards,
>
>
>
>
> On Sun, May 22, 2016 at 12:40 PM, Bhaskar Mitra <[hidden email]
> >
> wrote:
>
> > Hello, I am trying to merge two text files by using the timestamp
> > header for both the files:
> >
> > The first file has the following format for the timestamp:"2012-01-01
> > 23:30:00 UTC"
> >
> > Timestamp for the second file : 2012-01-01 2330.
> >
> > I am having problems by converting from one timestamp format to another.
> > Any suggestions/help in this regard?
> >
> > regards,
> >
> >
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Merging 2 files with different timestamp

David Winsemius
In reply to this post by Bhaskar Mitra

> On May 22, 2016, at 9:40 AM, Bhaskar Mitra <[hidden email]> wrote:
>
> Hello, I am trying to merge two text files by using the timestamp
> header for both the files:
>
> The first file has the following format for the timestamp:"2012-01-01
> 23:30:00 UTC"
>
> Timestamp for the second file : 2012-01-01 2330.

> as.POSIXct("2012-01-01 23:30:00 UTC",format="%Y-%m-%d %H:%M:%S", tz="UTC")
[1] "2012-01-01 23:30:00 UTC"
> as.POSIXct( "2012-01-01 2330", format="%Y-%m-%d %H%M", tz="UTC")
[1] "2012-01-01 23:30:00 UTC"

>

> I am having problems by converting from one timestamp format to another.
> Any suggestions/help in this regard?
>
> regards,
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Merging 2 files with different timestamp

Jeff Newmiller
In reply to this post by Jeff Newmiller
You have by now seen some other responses on the list. Keeping the list
included will insure you continue to get mulitple eyes looking at the
problem and will benefit others trying to use the answers.

Two comments:

1) Your first format includes a specification for seconds. If that is
nonzero at any point you could have difficulty aligning that data with the
second format. In some cases this may be desirable, in other cases you may
prefer to use some kind of "nearest minute" calculation such as
trunc.POSIXt or round.POSIXt might yield. If you do so, be aware that
those functions always return POSIXlt, and efficient computation is
usually obtained with POSIXct, so convert if you have to.

2) It is not necessary to convert back to character as Jim Holtman
suggests in order to merge the data... working with POSIXct data type
directly will be more efficient. I would warn against using POSIXlt for
merging, though, for poor efficiency reasons.

On Mon, 23 May 2016, Bhaskar Mitra wrote:

> Dear Jeff,
> Time zone is UTC. No, daylight savings time does not apply.
>
> regards,
> bhaskar
>
> On Sun, May 22, 2016 at 4:10 PM, Jeff Newmiller <[hidden email]>
> wrote:
>       What time zone are these data in? Does daylight savings
>       adjustment apply?
>       --
>       Sent from my phone. Please excuse my brevity.
>
>       On May 22, 2016 9:48:08 AM PDT, Bhaskar Mitra
>       <[hidden email]> wrote:
>
> Hello,
> My apologies for the earlier posting. There was an error with regard to my
> query :
> I am trying to merge two text files by using the timestamp
> header for both the files:
> The first file has the following format for the timestamp:"27-Dec-12 23H
> 30M 0S"
> Timestamp for the second file : 2012-12-27 2330.
> I am having problems by converting from one timestamp format to another.
> Any suggestions/help in this regard?
> regards,
> On Sun, May 22, 2016 at 12:40 PM, Bhaskar Mitra <[hidden email]>
> wrote:
>  Hello, I am trying to merge two text files by using the timestamp
>  header for both the files:
>  The first file has the following format for the timestamp:"2012-01-01
>  23:30:00 UTC"
>  Timestamp for the second file : 2012-01-01 2330.
>  I am having problems by converting from one timestamp format to another.
>  Any suggestions/help in this regard?
>  regards,
>  [[alternative HTML version deleted]]
> ____________________________________________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>
>

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<[hidden email]>        Basics: ##.#.       ##.#.  Live Go...
                                       Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------
______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.