Export CSV Cmdlet goes to infinite loop

I’m trying to aggregate data from various CSV’s into one using the following line of code

“ ls -n *.csv | %{ ipcsv $_} | epcsv allinone.csv -NoTypeInformation “

It worked fine until I changed the exported csv name to OneWorldFile.csv. It looks like PS lands into an infinite loop and appends the data into the CSV. I’ll have to eventually halt the process.

“ ls -n *.csv | %{ ipcsv $_} | epcsv OneWorldFile.csv -NoTypeInformation “

Here is the screenshot for your verification : http://note.io/1pNoee3. Is there any reason for this behaviour? Did I miss something?
Thank you in advance for your reply.
Vimal.

Also, I happened to notice that this behaviour happens only if the resultant CSV starts with the name of any other existing csvs inside the directory. Yes, I don’t face any problems if I export the aggregate CSV to another directory.

Seems to be an issue with pipeline input for Import-Csv. I can replicate the issue. The issue doesn’t occur when I provide the items to Import-Csv via parameter input instead of pipeline input.

Import-Csv -Path (Get-ChildItem -Name *.csv) | Export-Csv -Path .\OneWorldFile.csv -NoTypeInformation

As long as you exclude your output file from Get-ChildItem, I suspect it’ll work either way.

ls -n *.csv -ex OneWorldFile.csv | %{ ipcsv $_} | epcsv OneWorldFile.csv -NoTypeInformation

Thank you, Mike and Dave.