Importing .CSV showing many NULL character?

Ask your 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.
This topic is 4 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
ITEngineer
Posts: 216
Last visit: Thu Mar 23, 2023 5:45 pm
Has voted: 4 times

Importing .CSV showing many NULL character?

Post by ITEngineer »

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Importing .CSV showing many NULL character?

Post by jvierra »

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: 216
Last visit: Thu Mar 23, 2023 5:45 pm
Has voted: 4 times

Re: Importing .CSV showing many NULL character?

Post by ITEngineer »

jvierra wrote: Sun Nov 24, 2019 8: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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Importing .CSV showing many NULL character?

Post by jvierra »

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.
This topic is 4 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked