cancel
Showing results for 
Search instead for 
Did you mean: 

Put CSV Output on New Lines ?

dunncrew
Deputy Chef III
Deputy Chef III

I am reading 1 text field from a SQL Server select rows and want to send them in an email. Currently, it puts all the records on one line, but I want each record on a new line. Any suggestions ? I tried to force a "New line" break, but no luck.

See Screen-shots and result data (3 records sample) below.

Instead of this

    10/11/2023  10:16     Jones, Mary,   Computer Room    ,    10/11/2023  10:54     Smith, Frank,   Computer Room    ,    10/11/2023  15:56     Amos, Henry,   Computer Room   

I want

10/11/2023  10:16     Jones, Mary,   Computer Room     

10/11/2023  10:54     Smith, Frank,   Computer Room   

10/11/2023  15:56     Amos, Henry,   Computer Room  

dunncrew_0-1697144608116.png

dunncrew_1-1697144623817.png

 

 

 

 

1 ACCEPTED SOLUTION

dunncrew
Deputy Chef III
Deputy Chef III

Thanks. I think the output is correct when I do this:

dunncrew_0-1697148126645.png

But after the next step to send the email

dunncrew_1-1697148193921.png

I get this error.

dunncrew_2-1697148257175.png

Also, It looks like I can "trick" it into making a 2 dimensional array by PLUCKing a blank instead of a 2nd field, but it puts a comma off to the right to separate the imaginary 2nd blank field from valid field 1

P.S.  Thanks for all your help the last few days !

 

 

 

 

View solution in original post

8 REPLIES 8

gary1
Executive Chef II
Executive Chef II

When you pluck a single field, the result is a flat array of values, so using to_csv creates a CSV with a single row (no line breaks).

If you add a second value to your pluck it will make a two-dimensional array (an array of arrays), and to_csv will add line breaks between each secondary array.

If you don't want to pluck a second value, you can drop to_csv and use [rows].pluck('output').split('\n')

dunncrew
Deputy Chef III
Deputy Chef III

Thanks. I think the output is correct when I do this:

dunncrew_0-1697148126645.png

But after the next step to send the email

dunncrew_1-1697148193921.png

I get this error.

dunncrew_2-1697148257175.png

Also, It looks like I can "trick" it into making a 2 dimensional array by PLUCKing a blank instead of a 2nd field, but it puts a comma off to the right to separate the imaginary 2nd blank field from valid field 1

P.S.  Thanks for all your help the last few days !

 

 

 

 

gary1
Executive Chef II
Executive Chef II

Try setting the body input to text and not formula mode.

No problem! Happy to help : )

dunncrew
Deputy Chef III
Deputy Chef III

No error, but my email result is this:

[["10/11/2023  10:16     Jones, Mary,   Computer Room                                              ", "10/11/2023  10:54     Smith, Frank,   Computer Room                                              ", "10/11/2023  15:56     Amos,Henry,   Computer Room                                                   "]]