Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Trim CSV output

shilpamehta1991
6 - Meteoroid

Hello,

 

Is it possible to trim only the first and the last record of a CSV output and delete all the other commas and keep delimiters?

Please find the screenshots for reference.

 

Expected_Output.PNGCurrent_Output.PNG

14 REPLIES 14
shilpamehta1991
6 - Meteoroid

Thanks @Pratham @DavidP for your solutions.

 

So I have got rid of the trailing commas in the first and the last records however while outputting the records to csv the entire record is now coming under a quote. See below for reference.

 

Revised_Output.PNG

I suspect  when I will upload this file to any other system the entire record will only be considered as 1 field, which is not what I expect. Is there any way these quotes can be removed, so my fields aren't treated as single field?

 

 

Pratham
6 - Meteoroid

@shilpamehta1991 wrote:

Thanks @Pratham @DavidP for your solutions.

 

So I have got rid of the trailing commas in the first and the last records however while outputting the records to csv the entire record is now coming under a quote. See below for reference.

 

Revised_Output.PNG

I suspect  when I will upload this file to any other system the entire record will only be considered as 1 field, which is not what I expect. Is there any way these quotes can be removed, so my fields aren't treated as single field?

 

 


Well in the Output tool configuration of the CSV file, Alteryx does allow you to unquote your output fields, provided the delimiter you choose for your output file is not present in the records. This clearly not possible in your case, since you have the delimiter in the records.

 

So a simple workaround for this is to change the delimiter of your output file, let's say to a pipe character "|", just for the Output tool's sake and have the tool output your file with the "Quote output fields" option set to "Never".

Your output file still gets to be a comma-separated CSV file.

 

Have a look at the configuration and output below:

TrimFirstLastOP.png

shilpamehta1991
6 - Meteoroid

hi @Pratham , I tried your solution, looks good to me. 

Will try to upload on other system to see if gets through as well.

 

Thanks a lot!

 

danilang
19 - Altair
19 - Altair

Hi @shilpamehta1991 , @Pratham 

 

As opposed to specifying an artificial pipe "|" character as the field delimiter, Alteryx allows you to specify no delimiter "\0"  in the output configuration.

 

Dan

shilpamehta1991
6 - Meteoroid

@danilangyeah \0 works, thanks for your suggestion.

 

Regards,

Shilpa

Labels