Importing .CSV showing many NULL character?

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Post Reply
User avatar
ITEngineer
Posts: 171
Joined: Wed Oct 12, 2011 10:52 am

Importing .CSV showing many NULL character?

Post by ITEngineer » Sun Nov 24, 2019 9:41 pm

People,

I have just downloaded the .CSV from Office 365 with the content of Message Transport logs.

However, the Notepad++ showing it as NULL typed content as per below screenshot:

Image

How to correctly import this file so I can use it against the Powershell script correctly?

Code: Select all

Get-Content -path 'C:\Logs\MTSummary_Message trace report.csv' -first 2
Result:

Code: Select all

" o r i g i n _ t i m e s t a m p " , " s e n d e r _ a d d r e s s " , " r e c i p i e n t _ s t a t u s " , " m e s s a g e _ s u b j e c t " , " t o t a l _ b y t e s " , " m e s s a g e _ i d " , " n e t w o r k _ m e s s a g e _ i d " , " o r i g i n a l  
c l i e n t _ i p " , " d i r e c t i o n a l i t y " , " c o n n e c t o r _ i d " , " d e l i v e r y _ p r i o r i t y "
/* IT Engineer */

jvierra
Posts: 14016
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Importing .CSV showing many NULL character?

Post by jvierra » Sun Nov 24, 2019 9:46 pm

It is in Unicode and NP++ is not reading it correctly.
This has nothing to do with scripting or PowerShell.

If the BOM is missing then this can happen.

You can try to read it correctly with "Get-Content" and specify "Unicode" as the encoding.

User avatar
ITEngineer
Posts: 171
Joined: Wed Oct 12, 2011 10:52 am

Re: Importing .CSV showing many NULL character?

Post by ITEngineer » Sun Nov 24, 2019 10:25 pm

jvierra wrote:
Sun Nov 24, 2019 9:46 pm
It is in Unicode and NP++ is not reading it correctly.
This has nothing to do with scripting or PowerShell.

If the BOM is missing then this can happen.

You can try to read it correctly with "Get-Content" and specify "Unicode" as the encoding.
You sir are correct :-)

that is what has been missing so far :-)

thank you for the quick update.

it works as expected now.
/* IT Engineer */

jvierra
Posts: 14016
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Importing .CSV showing many NULL character?

Post by jvierra » Sun Nov 24, 2019 10:32 pm

I have another guess. I suspect you have an old copy of NP++ as it should have detected the correct encoding.

If it is a missing BOM then it was downloaded using the wrong encoding specification for the download.

Post Reply