# Export CSV Cmdlet goes to infinite loop

**URL:** <https://forums.powershell.org/t/export-csv-cmdlet-goes-to-infinite-loop/2746>\
**Category:** PowerShell Help\
**Created:** [June 24, 2014, 10:40pm UTC](https://forums.powershell.org/t/export-csv-cmdlet-goes-to-infinite-loop/2746 "2014-06-24T22:40:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vimal-sreedhar](https://avatars.discourse-cdn.com/v4/letter/v/c0e974/32.png) [@vimal-sreedhar](https://forums.powershell.org/u/vimal-sreedhar)\
**Post date:** [June 24, 2014, 10:40pm UTC](https://forums.powershell.org/t/export-csv-cmdlet-goes-to-infinite-loop/2746/1 "2014-06-24T22:40:11Z")

</div>

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 : [Windows 7](http://note.io/1pNoee3). Is there any reason for this behaviour? Did I miss something?  
Thank you in advance for your reply.  
Vimal.

---

<div class="post-metadata">

**Author:** ![vimal-sreedhar](https://avatars.discourse-cdn.com/v4/letter/v/c0e974/32.png) [@vimal-sreedhar](https://forums.powershell.org/u/vimal-sreedhar)\
**Post date:** [June 24, 2014, 11:31pm UTC](https://forums.powershell.org/t/export-csv-cmdlet-goes-to-infinite-loop/2746/2 "2014-06-24T23:31:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mikefrobbins](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/mikefrobbins/32/272_2.png) [@mikefrobbins](https://forums.powershell.org/u/mikefrobbins)\
**Post date:** [June 25, 2014, 4:37am UTC](https://forums.powershell.org/t/export-csv-cmdlet-goes-to-infinite-loop/2746/3 "2014-06-25T04:37:48Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [June 25, 2014, 6:14am UTC](https://forums.powershell.org/t/export-csv-cmdlet-goes-to-infinite-loop/2746/4 "2014-06-25T06:14:25Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![vimal-sreedhar](https://avatars.discourse-cdn.com/v4/letter/v/c0e974/32.png) [@vimal-sreedhar](https://forums.powershell.org/u/vimal-sreedhar)\
**Post date:** [June 25, 2014, 5:12pm UTC](https://forums.powershell.org/t/export-csv-cmdlet-goes-to-infinite-loop/2746/5 "2014-06-25T17:12:29Z")

</div>

Thank you, Mike and Dave.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:47pm UTC](https://forums.powershell.org/t/export-csv-cmdlet-goes-to-infinite-loop/2746/6 "2024-05-16T20:47:52Z")

</div>


