Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Iterate over a csv file (for each row)

mathias_schnoor
11 - Bolide

Hey!

I have a given CSV file.

How it is possible to iterarte over the csv-file (as a build macro, I think)

like:

for each row
    parse the row content
    do something with...
    add result for this row to an other csv file
    next row
...
I mean get for each row a single result at first and add the single result the other csv file.

My Example:
I have a result set in my csv file. Each content of the row is a XML syntax. )But the count of rows can be different).

When I parse the row to a specific child name I get four result child values (in my example) for specific child name for each row.
But I need only the first result child value.
And I kept on working on the first result value only.

The problem is the different count of my Input-Data file.
So I can never say the real count of rows.

Is there a solution to create a macro in Alteryx?

If the solution transferable to a database table.

Mathias

4 REPLIES 4
chris_love
12 - Quasar
This should be possible using XML parse tool and a sample tool to take
first row (grouping by row number is original file).

These tools will naturally iterate over the file and do what you need.

Then you can add to your csv at the end.

Of course I may be misunderstanding the problem....

Chris
mathias_schnoor
11 - Bolide

Hey Chris!

 

In my example I get after xml-parsing algorithmus 12 rows as result in my Browse-Tool. By given 3 rows to parse in the CSV-File.

I have a Record-ID Tool between the XML-Parse-tool and the Browse-Tool.

 

I need the row with the record-id 1, 5, 9 for a right solution.

 

By given 4 rows in the CSV-File. I get 16 rows after the xml-parsing algorithmus.

 

I need the row with the record-id 1, 5, 9, 13 for a right solution.

 

and so on ...

 

ParseCSVResult.PNGexample resultset

 

I don' t understood must can I use the Sample-Tool?

 

Mathias

 

 

 

 

 

 

AdamR_AYX
Alteryx Alumni (Retired)

Hi Mathias,

 

Try putting the Record ID tool in front of your XML parse.  That will then give you the orginial RecordId for each record after the XML parse.  Then you just want the first row for each RecordId.  So after the XML parse add a sample tool, set to "First N Records"; "N = " to 1 and Grouping Fields select your RecordId field.

 

XMLParse.png

Adam Riley
https://www.linkedin.com/in/adriley/
mathias_schnoor
11 - Bolide

Hey Adam hey Chris,

 

thank you for your support.

 

I get the results where I am looking for.

 

Mathias

Labels