Dynamic data import / export

datenbank

simply more productive
Up to 10,000 records can be processed with the freeware version!
Welcome, Guest
Username: Password: Remember me
Welcome to the FlowHeater support forum.

Questions about using FlowHeater are answered here.

TOPIC: Global Variables

Global Variables 5 years 7 months ago #2099

  • Francis
  • Francis's Avatar
  • Offline
  • New Member
  • Posts: 13
Hi again Robert!

I'm currently on a massive import of > 70 excels of the same frame that I'll handle with Forfiles command.

The problem here is that I have X rows ( random X ) for an information


ATA NAME DESCRIPTION


50 COMMUNICATION
LSA DESC A
ELT DESC B
COMPAS DESC C


75 CIRCULAR LOGIC
ALT DESC 1
GUI DESC 2



I need to create a row for each that contains each the '50' and '75' information in a certain field ATA.

Is there anyway to do this ?? I was thinking about global variable that changes everyime a new ATA is found, otherwise, the lastest value is took.


I joined an excel of the specimen so you'll be able to understand the request


Thanks ! And long life to your software !
The administrator has disabled public write access.

Re:Global Variables 5 years 7 months ago #2100

  • FlowHeater-Team
  • FlowHeater-Team's Avatar
  • Offline
  • Administrator
  • Posts: 240
Hi Francis,

I’ve made a simple example to explain this. Please have a look to the attachment dotnet_filter.zip.

The example uses the following .NET Script to remember the certain field ATA. If the field content is numeric, the ATA number is stored for the next and following rows.

NOTE: For the group header row the .NET Script heater returns an empty string!
string lastATA = String.Empty;

public object DoWork()
{
  string ata = (String)InValues[0].GetString();
  if (ata != null)
  {
    if( IsNumeric(ata) )
    {
      lastATA = ata;
      return ""; // we want to filter the first group header row!
    }    
  }

  return lastATA;
}

private bool IsNumeric(string s)
{
  int i;

  if (Int32.TryParse(s, out i))
    return true;

  return false;
}

In the next step, the ATA number form the .Net Script Heater are checked with the If-Then-Else Heater for the Condition

not equal 50 and not equal 75

In this case the Filter Heater filters the given rows. Only rows with ATA number 50 and 75 are passed.

If I’ve understand your request not correct please add your example data as a ZIP archive. Only ZIP files are allowed!

Attachment dotnet_filter.zip not found

Attachments:
Best wishes
Robert Stark

Did this answer your question? We would be grateful if you provide a brief comment as feedback. It may also help others who may have encountered a similar problem.
The administrator has disabled public write access.

Re:Global Variables 5 years 7 months ago #2101

  • Francis
  • Francis's Avatar
  • Offline
  • New Member
  • Posts: 13
That's exaclty what I need !

But in your exemple, you hardcoded 50 and 75 in an IF heater. Is there a way to do determinate those run-time. I have to do it for 60 excels that I won't know each ATA number.

The logic is exactly what you posted as exemple, but with a mecanism group by ATA dynamically.

I don't know if you understand my request well ?? I'll post an exemple if not
The administrator has disabled public write access.

Re:Global Variables 5 years 7 months ago #2103

  • FlowHeater-Team
  • FlowHeater-Team's Avatar
  • Offline
  • Administrator
  • Posts: 240
The only way is to read the conditions form a file with a second .NET Script Heater.

Replace the If-Then-Else Heater with one more .NET Script Heater and copy the following script into it.
string [] sConditions = null;

public object DoWork()
{
  // Load conditions only first time
  if (sConditions == null)
  {
    sConditions = File.ReadAllLines("conditions.txt");
  }

  // get the first input parameter
  string sCmp = (string)InValues[0].GetString();
  if (sCmp == null)
    return true;

  // check all conditions
  foreach(string cond in sConditions)
  {
    if (sCmp == cond)
      return false; // false = no filter, pass this line
  }

  return true; // true = Filter this line
}

The script read at start time the conditions dynamically from a text file "conditions.txt" in a global string array. Per each row the script check if the ATA number match each of one row form the text file.

I’ve modified the example with this script and have putted also the GroupBy Heater to the example.

If I've misunderstand you please describe a bit more what you want and send some example. Source format and destination format are helpful.

Attachment dotnet_filter02.zip not found

Attachments:
Best wishes
Robert Stark

Did this answer your question? We would be grateful if you provide a brief comment as feedback. It may also help others who may have encountered a similar problem.
The administrator has disabled public write access.

Re:Global Variables 5 years 7 months ago #2105

  • Francis
  • Francis's Avatar
  • Offline
  • New Member
  • Posts: 13
Wow ! exactly this !

Global variables in imports are so usefull, incredible !

Thanks again, you always have answers. This software has really no limits !
The administrator has disabled public write access.
Moderators: FlowHeater-Team
Time to create page: 0.081 seconds