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?
Solved! Go to Solution.
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...
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.
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"
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" ?
you can check that Treat errors as warnings check box in Dynamic IP tool
click edit then you can see that option
Of course! <hitting the wall>.. thanks a lot!
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?
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
User | Count |
---|---|
17 | |
15 | |
15 | |
8 | |
5 |