Free Trial

Alteryx Designer Desktop Discussions

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

Reading other types of files as Text

dawid_nawrot
9 - Comet

I have a rather unusual request.. 

 

Let's assume I want to read JavaScript file as text (whole directory in the future). I've tried using INPUT TOOL and read it as CSV with 0 as a delimiter, it still outputs the file in multiple rows but I can use SUMMARIZE with CONCATENATE. 

 

But how do I do it for multiple files? The above is concatenating all files together.

 

Or is there a better way to read any file that I want and treat it as one big blob of text?

9 REPLIES 9
RodL
Alteryx Alumni (Retired)

If I'm understanding you correctly, you have multiple JavaScript files and you'd like each file to be a separate record in the output of concatenated scripts?

What you would do is turn your current process into a batch macro. Then what you would feed into the macro would be the output from a Directory tool that would provide the list of each of the JavaScript files. The batch macro will process each record from the Directory tool separately and then output a record for each file.

 

Here are some resources you might find helpful...

Help on the Batch macro

On-demand video for how to build a batch macro

NeilR
Alteryx Alumni (Retired)

You should be able to do it by making sure the "Output File Name as Field" option in the Input tool is "Full Path" or "File Name Only", then adding a GroupBy on this new field in the Summarize tool. See attached. My example works with subdirectories as well, but you can uncheck that option if you prefer.

dawid_nawrot
9 - Comet

What if one of the files is empty? I selected "Treat errors as warnings" but Alteryx still thinks it's an error just because "file has no fields"

NeilR
Alteryx Alumni (Retired)

In that case you could use a Directory tool to get the list of files, filter for size > 0, then same as before except a Dynamic Input tool instead of Input tool, see attached.

dawid_nawrot
9 - Comet

Almost there.. now I'm getting "too many fields in a record" but I guess in DYNAMIC INPUT I can't select "Treat errors as warnings" ? 

s_pichaipillai
12 - Quasar

you can check that Treat errors as warnings check box in Dynamic IP tool 

click edit then you can see that option

DIP.PNG

dawid_nawrot
9 - Comet

Of course! <hitting the wall>.. thanks a lot! 

NeilR
Alteryx Alumni (Retired)

I'm curious why you're getting the "Too many fields" warning at all - with a null (\0) delimeter I wouldn't think you'd ever get more than one field. Would you be able to share the file that is causing the error?

ScottK
5 - Atom

In case anyone comes back to this thread, I ran into a similar issue - trying to read in a csv file just as text so that I could later massage the data.  

 

I noticed in the results window that it was changing the 'Autodetected CodePage: UTF-8', and I expect that this triggers some kind of reset during batch processing.

 

Changing input tool option for Code Page to 'Unicode UTF-8' resolved the error and all files were parsed into a single field.

 

Cheers,

Scott

Labels
Top Solution Authors