Alteryx Designer Desktop Discussions

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

Earn txt file's names and its delimiter in a directory

Saraabdi955
8 - Asteroid

Hi,
I have a large number of text files in a folder, each with separate columns. I want to get list of names of all the files and its delimiter to be written in a different column.
Please help me how can I do this?

11 REPLIES 11
joshuaburkhow
ACE Emeritus
ACE Emeritus

Hey @Saraabdi955 For a list of all the files in that directory/folder you can use the directory tool to get that. However I am not clear on the delimeter part of the request. Are you saying each of those txt files have different delimeter's? 

Joshua Burkhow - Alteryx Ace | Global Alteryx Architect @PwC | Blogger @ AlterTricks
pedrodrfaria
13 - Pulsar

Hi @Saraabdi955 

 

As @joshuaburkhow  mention, you can simply use a directly tool to load all the file names into Alteryx. I added below a visual representation of this for educational purposes:

 

pedrodrfaria_0-1610022664074.png

 

Pedro.

Saraabdi955
8 - Asteroid

yes, exactly.

each text files has different delimiter such as : or , or | etc.

I want to have a column behind of file's names.

like as this:

File NameDelimiter
test_1,
test_2:
test_3,
test_4:
DavidP
17 - Castor
17 - Castor

Hi @Saraabdi955 

 

Here's what I'm thinking:

 

DavidP_0-1610024741092.png

 

Use the Directory tool as suggested, then use a Dynamic Input tool where the template file has the following settings:

 

1 Record Limit set to 1

2 File Format set to csv

4 Output File Name as Field set to Filename Only

5 Delimiters set to \0

6 Uncheck First row contains Field names

 

Under Read a List of Data Sources, set Field: to Fullpath and set the Action to Change Entire File Path

 

The regex tool can now extract the delimiter used for each file.

 

Saraabdi955
8 - Asteroid

Thank you for helping me,

is it possible to check my workflow, please?

I have two questions:

1. why the Join macro hadn't any output? what's the problem?

2. why \t could not determine as a delimiter?

DavidP
17 - Castor
17 - Castor

Hi @Saraabdi955 

 

Could you please attach some sample txt files. 

 

Also, can you attach the macro that you're using after the join tool.

Saraabdi955
8 - Asteroid

Sorry,I forget it.

Thanks a lot

DavidP
17 - Castor
17 - Castor

Hi @Saraabdi955 

 

There we a couple of problems - I'll go through them one by one.

 

1. The join tool: The left input used filename with an extension (.txt) while the right input didn't have one, so you have to make them the same. I added ".txt" to the right input with a formula tool.

 

2. The macro: There's 2 things you want to change inside the Input data tool in the batch macro, the filepath and the delimiter, so therefore you need 2 control parameters, one for each.

 

3. If the delimiter is a tab, you'll have to use a formula to change it to \t so that it can be used in the Control Parameter that updates the delimiter in the macro. I used the ChartoInt([Delimiter]) function in the formula tool before the Join Tool to see what the ASCII value of the tab is and then used that in an if statement to change it to \t.

 

Have a look at the attached and let me know if you have any further questions

 

DavidP_0-1610038186310.png

DavidP_1-1610038328673.png

 

 

Saraabdi955
8 - Asteroid

Thank you very much,

I have only one question:

if delimiter of all records was \t, it's not possible separate each of words in records.

How can I solve it?

Regards

Labels