Combining text files with dates and missing data
Mostrar comentarios más antiguos
I have numerous files in this format
YEAR MONTH DAY HOUR MIN VAL
1999 1 1 0 0 123
where the file contains data for a single year, month runs 1-12, day from 1-30 (or 28,29, or 31), hour goes from 0-23 and min almost always 0 and val represents a different type of value depending on the file (i.e. one file will have speed, another the mass, another the temperature of the object, etc.).
I want to combine the text files so that they end up like this
YEAR MONTH DAY HOUR MIN VAL1 VAL2 VAL3
1999 1 1 0 0 123 321 123
up to 7 values.
My problem is when data is missing/not recorded in one of the text files (e.g. Jan 1st 1999 Hours 0-23 has data but the next row is Jan 3rd 1999 Hour 0). When the data is missing, I'm not sure what to do as the arrays become uneven and I can't concatenate them unless I somehow fill in the gaps.
Is there a way to fill in any gaps with a blank or some non-data value like 99999 so that I can combine them? Or is there another way to combine the files? The latter is my goal.
6 comentarios
Walter Roberson
el 12 de Ag. de 2015
Would it be acceptable to add a delimiter between the fields such as comma or tab?
When the minute is not 0 then should that be treated differently from an entry that is 0? For example if you had 5 values in a row with the same information and minute 0 and then the next one had the same except minute 1, should that start a new line or should it be included in the previous?
Cas Cas
el 12 de Ag. de 2015
Walter Roberson
el 12 de Ag. de 2015
Oh wait, those values are to be accumulated across files ? Are there exactly 7 files?
Would you happen to be using OS-X or Linux? If you are, then I suggest you work outside of MATLAB, such as by using fsdb
Cas Cas
el 12 de Ag. de 2015
Walter Roberson
el 12 de Ag. de 2015
To check: for each year there are 7 files? Or is there only 1 file that has 7 types of values in it? If it is 1 file that has 7 types of values in it, how do you tell which value-type a particular line is?
Cas Cas
el 12 de Ag. de 2015
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Data Type Identification en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!