Classic file types are no longer available for use as of January 2021. You can transition your classic files or download a PDF. Learn More

How do I create a CSV file by hand in Chains?

Answered
0

Comments

4 comments

  • Jeff Hickey

    As documented in the Stack Files command "The header row from the first file will be used in the new file." This means that the headers from the other files will be omitted. If you don't include a header, Chains will treat the first row as a header. If you want to keep the first row, it is important to include a header, even if it is just a blank row of commas.

    Take for example the following three Create file nodes run through Stack Files:

    Create file 1 - Text:
    Amortization of lease payments,,,,,

    Create file 2 - Text:
    Payment Number,Date,Payment,Interest,Principal,Balance

    Create file 3 - Text:
    1,2020-04-01,1000,0,1000,56516.71
    2,2020-05-01,1000,141.29,858.71,55658
    3,2020-06-01,1000,139.14,860.86,54797.14

    Result of Stack Files:
    Amortization of lease payments,,,,,
    2,2020-05-01,1000,141.29,858.71,55658
    3,2020-06-01,1000,139.14,860.86,54797.14

    File 1 only had one row, but from the documentation we know that it is used as the header in the new stacked file result.
    File 2 also had only one row, but it is treated as a header and therefore omitted.
    File 3 had three rows. After the first row is omitted (header), the second and third row are stacked in the result.

    Try adding a header (even a blank row such as ",,,,,") to files 2 and 3 to fix the output. Or you could put all the data in the Text field of a single Create file node to avoid having to stack the three files together to create one file.

    1
  • Jeff Hickey

    Hi Waldo, make sure the files you create have the same headers and the stack command should work better. Alternatively, if you have all of the data for your csv file you're creating, you could create it in one Create file node rather than splitting it into several and stacking them together.

    0
  • Waldo Nell

    As you can see above my headers align (6 columns each) yet the stack fails.  All CSV files do NOT have headers - I want to emit a single line and build a file. Only the last file has a header.

    I tried using Create File to build all the fields in one go but it was not clear how to enter multiple rows in one line.  \n does not seem to work.

    Indeed I get this:

     

    0
  • Waldo Nell

    Thanks I understand the behaviour of Stack Files now.  

    0

Please sign in to leave a comment.