COnvertCSV creating issue

sns 9,246 Reputation points
2022-01-30T10:08:52.117+00:00

I have data in text file as below which have been saved to .txt from .xlsx file. You can see that text data in the file below.

I tried multiple times but every time I am getting below warning. Please help where is wrong, is it something wrong with file content.
169633-notabletogetrow.png

Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Andreas Baumgarten 123.4K Reputation points MVP Volunteer Moderator
    2022-01-30T10:25:29.953+00:00

    Hi @sns ,

    it looks like in the line of "Contact = Ram" is a tab in the "Address City" column -> Hyd Hyderabad. Within a column of a tab separated file there should no tab inside the data.

    169568-image.png

    If it's not a tab but spaces it's fine.

    What are you trying to achieve with the two lines in the script?

    If you just want to read the content of the file with tab delimited data you can use this:

    $rows = Import-Csv -Delimiter "`t" -Path "c:\users\kumar\downloads\Customers.txt"  
    

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


1 additional answer

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2022-01-30T20:13:33.56+00:00

    The error says that member "ac" is already present. But I don't see any "ac" in the first line of the file.

    Here's a small demonstration of how to reproduce that error:

    $text = "ac`tac", "ac1`tac2"
    $rows = ConvertFrom-Csv -Delimiter "`t" -InputObject $text
    

    The screenshot of your Customers.txt file content does not agree with the error. Are you sure you're dealing with the correct file?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.