Append to CSV if it exists

Is there a recommended way to append to a CSV if it already exists?

My current approach is to export to a CSV and then use a Run Program transformation and then read the History file back in

powershell -command “Get-Content ExportPercentileCurrent.txt | Out-File -FilePath ExportPercentileHistory.txt -Encoding ASCII -Append”

I want to keep a running log of validation metrics between imports and use it to flag bad imports

I would do it similarly. Maybe only used not a powershell command, but a command line such as

copy /b a.txt + b.txt a.txt


type b.txt >> a.txt

PS. We have the option to append to a CSV file somewhere on our product roadmap either for v3.6 or 3.7. It would save extra Run Program transformation.

Thank you, using copy or type is good. I had initially experimented with Powershell since I was going to try and ignore the header if the file existed, but realized it’s easier to just filter it out in EasyMorph after the fact.

Alternatively, you can export/import without headers at all and only rename columns from generic Column1, Column2 on importing.

Attached is a project that will append to a tab delimited fileappend tab.morph (4.1 KB)
import tab.morph (1.3 KB)

It needs a subproject, import tab, to do the import to allow the synchronize to occur – otherwise there is an error on the first run

I was unable to remove the duplicate headers in a generic way, but that’s easy enough to do in the calling project with a filter.

1 Like