MATLAB: Simple data extration from notepad

dataextraction

Hi there. I have financial data in a notepad in the form of:
10/21/2002,0609,0.97270,0.97270,0.97260,0.97260,0,0
10/21/2002,0610,0.97260,0.97260,0.97260,0.97260,0,0
10/21/2002,0611,0.97280,0.97280,0.97280,0.97280,0,0
10/21/2002,0612,0.97290,0.97290,0.97290,0.97290,0,0
10/21/2002,0613,0.97290,0.97290,0.97290,0.97290,0,0
10/21/2002,0614,0.97290,0.97290,0.97290,0.97290,0,0
Now to brief you this is data for 1 minute data 24 hours a day and 5 days a week. Each entry is on a new line with no spaces.
I want to transfer this data to MATLAB…but I want a easy method to select certain periods…For instance lets say I want period of 0600 – 0800 only for the historical data.
Additionally for anybody very clever is there a way I can select certain dates and time constraint like 10/28/2003 0600-0800.
I look forward to some answers.
Thanks

Best Answer

Here's an approach I would try:
1. Use csvread() to read in only the first two columns, the dates and times.
2. Use the datenum() function to convert these to serial date numbers.
3. Use the datenum() function to convert the desired dates and times to serial date numbers.
4. You should now be able to figure out exactly which rows to read. Use csvread() again to read only those lines of data.
The goal is to read only the data of interest from the file rather than reading in the whole file and then selecting the data of interest. I'm assuming that partially reading in a file using csvread() is faster than reading the whole thing, which I haven't tried. I would hope csvread() is that intelligent, though.
If your data truly are quite repeatable, then step 1 above could be replaced by reading in only the first date/time present in the first row. You could figure out the desired rows from just the first entry if they are absolutely repeatable. That would save you from having to read in all of the first two columns.
Good luck,
Eric