Looping through DataSets
Author: kiewo
Creation Date: 4/13/2018 1:51 PM
profile picture

kiewo

#1
Hi,

I have a question regarding datasets. I didn't find anything about that in the forum.

Is there a possibility to loop through several datasets?

Like...


CODE:
Please log in to see this code.


Thank you in advance!

profile picture

Eugene

#2
Hi,

There's almost always a way, and certain topics do exist on the forum: Iterate through DataSets. But before anything else let me find out what the real question is. Why do you think that looping through DataSets is required?
profile picture

Cone

#3
Here an example. This script finds all the DataSets (DataSources) that includes the clicked symbol, and, if mutual fund symbols are contained in one of those DataSets found.

CODE:
Please log in to see this code.
profile picture

kiewo

#4
Thank you for the quick response. However, that is not what I'm looking for.

The reason why I wanna loop through different Datasets is that I wanna export data for any symbols in the different datasets to ASCII files.
So it would be much easier for me to do that automatically than running the following code on each favored dataset:

Exporting to ASCII comma-separated files (CSV)
profile picture

Eugene

#5
Create one master DataSet that holds all of your symbols (use Watchlist Provider extension if necessary) and run that export script. No iteration necessary. That's why I asked you about the objective. It's a good support strategy to let technicians lead the dance. :)
profile picture

kiewo

#6
I know I can put all desired symbols in one dataset and run that export script. However, that is not what I'm looking for because I wanna have the symbols in different folders like they are located in the datasets (like all symbols belonging to the Dow30 in one separate folder, ...) How can I manage this by putting all symbols in one basket?
profile picture

Cone

#7
I think the easiest way is to use the Aronow Watchlist Provider extension to create a single DataSet that is comprised of symbols from other DataSets.
profile picture

Eugene

#8
Here's a solution for you kiewo. It will loop through DataSets and save the CSV to specified path.

Note that Windows won't let you save a file whose name contains restricted chars and sequences - like "CON.DE.csv" ("Continental" from DAX 30, for example). So it would be sanitized to _CON.DE.csv.

CODE:
Please log in to see this code.
profile picture

kiewo

#9
Eugene,

This is exactly what I need.
I modified the code so that only desired datasets are exported.
Thank you!
profile picture

Eugene

#10
Wolfgang,

Glad I could be of assistance.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).