Re: time stamp, file length



On Oct 27, 4:35 pm, "AP Pal" <avis...@xxxxxxxxx> wrote:
"Pekka Kumpulainen" <pekka.nospam.kumpulai...@xxxxxxxxxxxxx> wrote in message <hc3qt9$la...@xxxxxxxxxxxxxxxxxx>...
NZTideMan <mul...@xxxxxxxxx> wrote in message <08fabd78-88f1-4682-98a9-23f019ca5...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>...
On Oct 24, 5:27?pm, "AP Pal" <avis...@xxxxxxxxx> wrote:
NZTideMan <mul...@xxxxxxxxx> wrote in message <48966c20-cada-4db6-b021-fa06e3678...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>...
On Oct 24, 6:56?am, "AP Pal" <avis...@xxxxxxxxx> wrote:
Any ideas , any help?? Anyone?

"AP Pal" <avis...@xxxxxxxxx> wrote in message <hbqash$kp...@xxxxxxxxxxxxxxxxxx>...
I have mutiple files with different length, i need to make them all same length with time stamps , but some data are missing in some files
How do i stretch both files to make it same lenghth assigning 0 or blank to data pts which are missing.
?for example
file 1
10.20pm 23
10.30pm 50
10.40pm 60
10.50 pm 24

file 2
10.20pm 34
10.40pm 30
10.50pm 35

i would want
file 2 to read

10.20pm 34
10.30pm -
10.40pm 30
10.50 pm 35

Any help is highly appreciated
thanks a lot

Please don't top post.
It makes the thread hard to follow.
Put your reply UNDERNEATH.

What have you tried?
How do you think the data could be changed in a file as you propose?
I cannot think of any way this can be done using Matlab.
But perhaps you have something in mind?

If it were me, I'd use Matlab to do it in an entirely different way.

Can you tell me how you would do it?
i am trying this by generating a 3rd file and comparing it by timestamp of file 1 in a for loop. I am running into all kinds of problems. First problem is my file is in .csv and csvread ?reads only nums and disregards the date and time.

First thing you need to do is read the data into Matlab using
textscan.  It is more flexible than csvread.  You just tell it that
you are using comma for the delimiter, although the snippet of file
you showed us has space, not comma, as the delimiter. You will need to
sort this out in your head first.

Now you need to read up about datenum because the next step is to
convert those times into Matlab days.
Unfortunately, there could be a problem with the "pm"s. There seems to
be a random space between the time and pm.  Sometimes it's there, but
other times it's not.  You will have to think of a way around this.

Once you convert the times into Matlab days, you can figure out if
there is a time missing by using the function diff.

Then, you just insert a line at those points where the interval is
larger than expected.
You can write the file off using fprintf.

Some more tips..
If file1 includes all the time instances you need, you can preallocate the data for new file2 with zeros, same size as the data of file1 (a column vector in this case?).
newd2 = zeros(n,k);
Find where the timestamps of file2 are included in file1
doc intersect
[ts, ia,ib] = intersect(t1,t2);
it will give you the indices you need. You can use either datenums as suggested above, but intersect works with cells of strings too. However it looks for exact match, so the same time with and without space between the time and pm will not match.
Then fill the new data from the original file2 to the rows given by intersect
newd2(ia,:) = oldd2;
Then write the file.

If you need full regularly spaced timestamps and are not sure that file1 includes all. Then you can make the new final timestamps and repeat the stuff given above to both files, comparing to the timestamps you created.
hth

====================================================

date time              M01       M02     M03     M04     M05     M06
8/15/2009 0:00  5.8     7.8     7.8     7.3     0       7.9
8/15/2009 0:10  7.1     8.1     8.1     7.7     0       8.1
8/15/2009 0:20  6.8     7.4     7.6     7.1     0       7.3
8/15/2009 0:30  5.6     6.8     7.1     6.6     0       6.8
8/15/2009 0:40  3.9     6.2     6.4     6.2     0       6.4
8/15/2009 0:50  4.6     5.5     6.1     5.8     0       5.6
8/15/2009 1:40  7       7       7.2     6.9     0       6.3

Can you help me to read this .csv file  properly so i can convert the first column into a string using datenum. csvread ofcourse does not work. With textscan i am lost how to call it , so i do not get errors. The date and time are in same column.

Thanks
====================================================

Why do you keep saying this is a .csv file, when then are no commas?

Step by step, here is what you do (see help textscan for details):
1. Open the file using fopen.
2. Figure out the format. In the snippet you have given us, the
delimiter is space, so you will need to read in the date and time
separately using %s for each, then you have 6 floating point numbers,
so you need a %f for each of those.
3. Specify the delimiter as space
4. Specify there is one header line.
5. Read the data in.

You need to try figuring this out and post your code.
We'll help de-bug it, but don't expect people to write the code for
you.
If you're lucky, someone will do it for you, but it won't be me
because that way, you'll never learn and you'll keep on pestering us.
.



Relevant Pages

  • Re: time stamp, file length
    ... How do i stretch both files to make it same lenghth assigning 0 or blank to data pts which are missing. ... you showed us has space, not comma, as the delimiter. ... Can you help me to read this .csv file ?properly so i can convert the first column into a string using datenum. ...
    (comp.soft-sys.matlab)
  • Re: time stamp, file length
    ... How do i stretch both files to make it same lenghth assigning 0 or blank to data pts which are missing. ... I cannot think of any way this can be done using Matlab. ... you showed us has space, not comma, as the delimiter. ... You can use either datenums as suggested above, but intersect works with cells of strings too. ...
    (comp.soft-sys.matlab)
  • Re: Reading just one field of a comma separated line
    ... where the values represented by firstfield* were the desired strings, ... :>> comma, ... :>> first field. ... :> embedded comma from a delimiter comma? ...
    (microsoft.public.vb.general.discussion)
  • Re: Subtotals technical question
    ... In excel, the most common delimiter is usually a comma, but could be ... For me, it's the comma. ... lists. ... Or you can specify "delimited" and be able to choose your delimiter (even type ...
    (microsoft.public.excel)
  • RE: Trying to split up info in one cell to several
    ... Using Excel '03, I tried what you're having a problem with and seemed to ... Started with this in one cell: |1015 Bond St., Suite 299, Baltimore, MD ... Used Text to Columns, Delimited, set delimiter to Comma & removed check ... Comma, and in Step 3 clicked to select first column & set option to Do Not ...
    (microsoft.public.excel.misc)