Sign in to follow this  
Followers 0
automationexpert12345

Creating a dynamic set of variables automatically from a CSV

2 posts in this topic

Hi all,

I was wondering if anyone could offer any suggestions on how I might be able to accomplish the following:

I regularly work with large datasets in .csv form, and typically need to perform significant ETL (extract/transform/load) to the data in the file(s).

For example, if I have a date field in the CSV, I would want to use a combination of that field and the field name of the other 3-4 fields to create unique variables.

Example variables desired:

0501catA: (value: data from the catA field that corresponds to the 05/01 date)

0601catA: ...

0701catA: ...

0801catA: ...

0501catB: ...

0601catB: ...

0701catB: ...

0801catB: ...

...

I am very comfortable with AutoIt scripting - I'm just looking for logic suggestions (and perhaps code if you've done something like this) to automate this for hundreds (perhaps even thousand+ variables)

Limitations: I expect to generate hundreds of columns for the data and save that output to a much larger new .csv file. Please don't question why we do this, but know that the new .csv serves as a large input to a more complicated application that requires this type of input. The output must be copied directly to a new .csv and not to Excel / Access because of max column restraints.

Thanks so much for your time and assistance!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

Perhaps this get you going:

just did a quick copy...

--

If Not IsDeclared ($VIO_sty2) then; new var

Assign($VIO_sty2,$VIO_myvar1)

_ArrayAdd($VIO_VarList,$VIO_sty2); list of 'new vars in autoit

Else

Assign($VIO_sty2,Eval($VIO_sty2)); so.. leave as it is

EndIf

--

Basically, look at IsDeclared, Assign & Eval

Note the difference in $myvar and using Eval("myvar")

Make sure your vars are not already used somewhere else.

Hope it helps

Edited by heibel

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0