Export CSV Cmdlet goes to infinite loop

This topic contains 4 replies, has 3 voices, and was last updated by  Vimal Sreedhar 4 years ago.

  • Author
  • #16508

    Vimal Sreedhar

    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.

  • #16509

    Vimal Sreedhar

    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.

  • #16526

    Mike F Robbins

    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
  • #16530

    Dave Wyatt

    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
  • #16536

    Vimal Sreedhar

    Thank you, Mike and Dave.

You must be logged in to reply to this topic.