We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

CSV Batch Macro Error

SH_94
11 - Bolide

Hi Community,

 

I have built the batch macro input for CSV file based on the concept of xlsx but it seem like not working in this case as it show the error as below. Could anyone can help me to look into the alteryx solution and guide me which part need to be amended?

Basically i would like to ask the alteryx to read the csv file (which is different schema) and extract the following data

1. File name for each csv file

2. Each tab name for each csv file

 

SH_94_0-1620076382247.png

 

 

Thank you so much for your help.

14 REPLIES 14
Luke_C
17 - Castor
17 - Castor

Hi @SH_94 

 

Part of the problem is that csv files don't have sheet names, they are just text files at their core. If you really just need the file name the directory tool alone should work

SH_94
11 - Bolide

Hi @Luke_C ,

 

Thank you for your swift response.For the directory tools, will it work if i have the CSV file with different schema? Could you show me how it need to be amended in the workflow to deal with different schema files.

 

 

Thank you.

Luke_C
17 - Castor
17 - Castor

Hi @SH_94 

 

No problem. Are you looking to get the actual data from the files, or as your first post mentions just the file name? If it's just the filename the directory tool doesn't care about schema, putting *.csv as the file specification will return any csv files from the path you put.

 

If you need the data in each, I think you would need to provide a bit more information around what is ultimately expected as an output. 

SH_94
11 - Bolide

Hi @Luke_C ,

 

Yes. Basically i would like to extract the file name and data for each file (different schema).  The concept of the workflow which i would like to build is as per screenshot  below but i not sure how to amend it based on the workflow that i shared in the first post.

SH_94_1-1620078982054.png

 

Could you assist me on this on how can i build the workflow so that it able to read the data as per screenshot above?

 

Thank you again for your time.

 

Luke_C
17 - Castor
17 - Castor

Hi @SH_94 

 

Give this a try, it should work after I cut out a lot of the unneeded macros around sheets. If you're all set please be sure to accept the solution.

SH_94
11 - Bolide

Hi @Luke_C ,

 

Thank you for the prompt response.

 

Yes. It is the macro that i looking for . I have tried to use it to read my CSV file and noted that it give the errors as below.May i know how can i solve the issue in this case?

 

SH_94_0-1620111450282.png

 In addition, i just checked the file name and it shows in the format below which i not sure how to extract the file name from this column .

SH_94_2-1620111726633.png

Many thanks again for your help.

 

 

Luke_C
17 - Castor
17 - Castor

Hi @SH_94 

 

For the filename, change this setting in the input tool of the macro:

Luke_C_0-1620133692618.png

 

For the error message, this means that in row 67 of the file there are more fields than headers, for example, if your csv has 6 headers defined, and there is a row with 7 fields in it, you will get an error. This could be because of a stray comma or bad data. You can either correct the data at the source, or use \0 as the delimiter. \0 will make it so the data is read in as-is, and you could then use the text to columns tool to help parse the data appropriately. 

 

SH_94
11 - Bolide

Hi @Luke_C ,

 

Thanks a lot for your swift response.

 

It is working now and thanks again for the great explanation on how to modify and correct the error.

 

 

 

Thank you so much.

SH_94
11 - Bolide

Hi @Luke_C ,

 

I am trying to use the text to column function and it does not split the header name accordingly.May i know how can i fix this issue ?

SH_94_0-1620137888436.png

SH_94_1-1620137933398.png

Thank again for your help.

 

Labels
Top Solution Authors