Dynamic naming of output .txt and/or numerical arrays

1 view (last 30 days)
Okay, before I begin my question, let me clearly state what this question is NOT. This question is not asking on how to dynamically name variables or calculation variables within my script, I know that is a very bad thing and can really muck things up.
So, my question is, what is the best way to go about setting up a script that will read in a file from multiple sources that will be of many different lengths and contatin data from mulltiple sites that use multple different names. The information in each row has the "site id" in the first column which will be used to create an output .txt file to parse and save the data for later use.
I have a static version of this script and it will tear through 10K files in about 3 min and put all the data for 24 different .txt files named by their "site id" in a nice orderly set for later analysis by a different script. Each variable is named carefully to make sure this happens with no errors. This works for one AOR but I now need to look at other AORs and each AOR has a different number of uniquely named sites (this is important as this identifies the geographic location and this information needs to be perserved). So I need a way to name my output and temporay arrays dynamically so that I can read in any AOR but still get the resolution and fidelity that I currenty get with my "fixed name and length" script. I don't like the idea of creating 62 different ingest files. Not fun.
Any suggestions?
Eric Metzger
Eric Metzger on 6 Apr 2020
Here is what part of the ingest code looks like (it is nearly 1000 lines long so I won't put all of it in here).
for i=1: length(D)
file=D(i,:) .name; % pull the file to be processed
% Pull out date and other variables from the table, convert into a the
% formats that are needed to complete the function
% t = temporary variable to help parse date
% tv = temporary variable to help parse date
%convert to an array/num
% convert to a string
% pull out the year, month and date, save into indiviidual variables and
% convert them back to a number for later use
%place date information into an array and convert to a serial date using
date=[yr mm dy];
process=['Processing forecast file: ', file];
% Pull the individual station data out, store and then place into the
% needed mat file for later use and analysis
% Extract Actual storm total WFO QPF for specific sites
This continues each site and you can see it pulls date information and then nformation from each site. What I need is a way to make arrays dynamice instead of "wfoict". I use readtable as this is the best way to pull the data and get into the form needed for later processing. The attachement is an example of one of the 24 files this script creates. It is a basic output but very easy for MatLab to read an process later.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by