Extract data from to connected Excel files, as if one is function and the other its parameter values - matlab

My question has 2 parts.
Part 1:
I have 3 Excel files each with multiple sheets. I have loaded all files with sheets into the matlab using a small code. The files are loaded in a structured form. i.e. One main structure and 3 files as a seperate fields with multiple sheets as a value.
Part 2:
Now I have another seperate excel file having a single sheet with a single column. The col of this excel file has entries(or values/names) which are linked to each file of part one. In other words each excel file of part 1 is a data of each entry of a column of excel file in part 2.
Now my problem is that I want to link both of them. This is important because in further processes I want my program to run in a way that when I specify the value or tell the entry from excel file of part 2 it takes corresponding data from excel file of part 1. Is there any way of doing it?
This block diagram may be helpful to understand what I mean. BLock Diagram

Related

Exporting the results of an Anylogic experiment

I have built my model and run the experiment. I cannot seem to find where the data is stored.
I now need to conduct several runs and compare the results, I am using normally distributed repair times so the results should vary between runs without modifying parameters.
How can I keep the results of each run and then present them all in the same data set?
There are two main options for getting data out of your simulation
Using the internal AnyLogic database
Using external files like Excel or txt
Step 1: Setup your objects
Internal Database
Create an empty table with the columns you require
External object
Setup either an Excel or text file using the objects provided by AnyLogic in the Connectivity palette
Step 2: Saving your data
For both cases you need to write your data to the object of your choosing, either as the data gets generated or at the end of the simulation model
using Internal DB
The best option is to write data using the following command
insertInto(table_name)
.columns(column_name)
.values(value);
This will just insert a new line into a database table that you created, you can save multiple values to multiple columns by adding comma-separated entries into the parameters for columns and values.
e.g
insertInto(temeprature_output_table)
.columns(scenario_name, time, temperature)
.values("sceanrio1", 10,5, 102);
External files
2.1) Using Excel
filename.setCellValue(value, sheetName, row, column);
or even better you can write out an entire dataset
excelFile.writeDataSet(dataset, sheetName, row, column);
2.2) Using a text file
fileName.println("value" + "\t" + " value 2");
You can use whatever separator you want "\t" for tab separated or "," for comma and so on
Step 3: Finish and export data
Internal Database
At the end of a simulation run, you can simply export the data
See help here https://anylogic.help/anylogic/connectivity/export-excel.html#exporting-data-to-ms-excel-workbook
P.S. It is possible to automate this with some effort
External file
On Excel you need to call .writeFile() to finish.
On both objects, you need to call .close() for them to be closed and saved to memory.
FYI
Excel has the option to save on termination.
Read more on using Excel here - https://anylogic.help/anylogic/connectivity/excel-file.html#writing-to-excel-file
And on text file here
https://anylogic.help/anylogic/connectivity/text-file.html#replicated
There is also an example model

Octave GNU - Searching multiple folders and their files at different points in program within cd

I have been struggling with this issue for a few days now and I decided to see if someone more experienced could help me out. I am currently developing a data analysis program designed to load and manipulate various data files. I have 3 folders each with 1 type of 30 files, represented by trial_001...trial_30, trial_n3d_001...trial_n3d_030, and trial_com_n3d_001...trial_com_n3d_030. These files are similar but possess differences in terms of types of data as well as total number of data columns and rows. Currently, the portion of my code for loading the data looks like this:
cd = dir('*.csv');
n = length(cd);
data = cell(1,n);
for files = 1 : n %For the first file up to the total amount of files
data(files) = csvread(cd(files).name); %Read in csv files
endfor
data = cell2mat(data); %Create single large dataset
This is successful in looping through my current working directory and obtaining all files and then inputting them into a single large dataset which is intended. I am able to perform all of my calculations. The problem is that I cannot seem to specify subfolders with this method, rather it only works if I manually load directly from one of the folders. I need the program to work on multiple computers and I would prefer if I did not have to set the loadpath within the code each time and simply use the path I choose manually when starting octave in the file browser and instead specify generic folder names.
So my question is how do I do exactly what I am doing currently but from the previous folder containing all three folders and their respective files, and search each of these folders at different points in my code? I want my data variable to act as a working dataset, and load in each of the three types of files at different times and perform different calculations (effectively resetting that data variable after loading all files from each folder and performing calculations). I have tried addpath, genpath, etc. as well as manipulating the common directory and creating variables representing each folders location but I cannot seem to get it to work. Any suggestions?

Two different mappings to ONE XML output file

I'm working on a talend job where I have a excel file and a couple of database fields that gets mapped to an XML file.
The working job looks like this:
Problem: I want to, with the same input of the excel file and the database fields, make another mapping that outputs to the same working XML file mentioned ealier. So I will have ONE XML file with TWO different mappings. How can I achieve this?
Update
I have done this mapping:
which in the end gets exported like this:
but I'm unsure on how to use this mapping in the tAdvancedFileOutputXML
If I understood correctly, you want to have a single XML file containing two different XMLs (the second one appended to the first one). In the shown Job add a OnSubJobOk link to point to a duplicate of your document flow which has a different mapping. In the second flow rather than using tFileOutputXML component to write the XML file, you can use the tAdvancedFileOutputXML with Append Source XML File marked to add to the file generated from the first flow. Also make sure to configure the XML tree. Check the following link for further information https://help.talend.com/reader/~hSvVkqNtFWjDbBHy0iO_w/h3wZegFH1_1XfusiUGtsPg
Hope this helps.

Using Talend Open Studio DI to extract extract value from unique 1st row before continuing to process columns

I have a number of excel files where there is a line of text (and blank row) above the header row for the table.
What would be the best way to process the file so I can extract the text from that row AND include it as a column when appending multiple files? Is it possible without having to process each file twice?
Example
This file was created on machine A on 01/02/2013
Task|Quantity|ErrorRate
0102|4550|6 per minute
0103|4004|5 per minute
And end up with the data from multiple similar files
Task|Quantity|ErrorRate|Machine|Date
0102|4550|6 per minute|machine A|01/02/2013
0103|4004|5 per minute|machine A|01/02/2013
0467|1264|2 per minute|machine D|02/02/2013
I put together a small, crude sample of how it can be done. I call it crude because a. it is not dynamic, you can add more files to process but you need to know how many files in advance of building your job, and b. it shows the basic concept, but would require more work to suite your needs. For example, in my test files I simply have "MachineA" or "MachineB" in the first line. You will need to parse that data out to obtain the machine name and the date.
But here is how may sample works. Each Excel is setup as two inputs. For the header the tFileInput_Excel is configured to read only the first line while the body tFileInput_Excel is configured to start reading at line 4.
In the tMap they are combined (not joined) into the output schema. This is done for the Machine A Excel and Machine B excels, then those tMaps are combined with a tUnite for the final output.
As you can see in the log row the data is combined and includes the header info.

Word Template Linked to Excel

I have an Access database that creates a Word document based on a Word template. In that template are a bunch of Charts, which in order to change their data, I have to programmatically launch an instance of Excel for each chart, change the data, then update. This is not only distracting as it flashes each Excel worksheet up on the screen then disappears, but it's incredible slow.
It would be great if the Word template could be linked to an Excel workbook where each chart is linked to that one workbook. Then, I could update the Excel file and the Word doc separately. Much faster.
The problem is, I would require there to be a separate Excel file for each Word doc. Basically I'd need a Word template to link to an Excel TEMPLATE. Then when the new Word doc is created from it's template, it's linked Excel stuff is linked to a new Excel file based on an Excel template.
Does this make sense? I just can't all Word docs linked to a single Excel file.
Thoughts?