Skip to main content
Cadet | Tier 2
August 31, 2022
Question

I am trying to write a table to a csv file, but the contents of each row are being stored in a single cell. I have tried using different row and column delimiters but nothing is working. Does anyone know how to fix this?

  • August 31, 2022
  • 5 replies
  • 1143 views

imageimage

    5 replies

    Cadet | Tier 2
    August 31, 2022

    Hello, I think you are missing enough information to be able to answer well, but I assume you are referring to the Data Table action: Write to file? If memory serves, that action sometimes does not work well for me also.

     

    Depending on the volume/density of data you are working with you can do something like this, using Loop and Log to file action:

    imageIn the first line I log my column headers to a csv file, separated by a comma. For this step make sure to select Overwrite file, if you want to make a new file each time this process runs.

     

    Then I loop through the data table, for each row assigning that row to variable TableRow, and then accessing each column either through the header names (FirstName/LastName) within curly braces, or the column index (uses 0 based index) with square brackets. Then I write those vales to the csv file, again separated by a comma. For this step make sure to choose append to file.

     

    imageLines 3 and 4 are not necessary, as you can use the TableRow{Value} directly in the Log to file action, but I wanted to illustrate the different ways to access the row data.

     

    Hope this helps!

    Liam 3192Author
    Cadet | Tier 2
    September 1, 2022

    Thank you, I will give this a go

    Ashwin A.K
    Navigator | Tier 3
    September 2, 2022

    Hi @Liam O'Dowd​ ,

     

    There is an Action called Data Table: Write to File which lets you write data to CSV in a single step.

    imageCould you give this a try and let us know if it works out for you?

     

    Kind Regards,

    Ashwin A.K

     

    Blogs at TheCodingTheory - https://www.thecodingtheory.com
    Cadet | Tier 2
    June 9, 2023

    Hi @Liam O'Dowd​ ,

     

    There is an Action called Data Table: Write to File which lets you write data to CSV in a single step.

    imageCould you give this a try and let us know if it works out for you?

     

    Kind Regards,

    Ashwin A.K

     

    Hi Ashwin.
    I’m having the same problem. The activity Data Table: Write to File does not separate columns and rows as it supposed to do. Do you have a fix or there is a bug?

    Cadet | Tier 2
    April 19, 2024

    Hello, 

    I wanted to use Row delimiter : new line on DataTable write to file action but it still not working !! Any news about that ?

    Waiting, I use coma as row delimiter, get text from file into which I write table and replace coma with stringNewLine variable as below : 

     

     

    In my case I have 150 rows and only one column so it is relatively simple.

     

    Hope this helps !