Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Windows 7 Forum Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

import-csv missing charakters

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 05-30-2007   #1 (permalink)
Christoph Jandek
Guest


 

import-csv missing charakters

Hello,

Using the powershell cmdlet IMPORT-CSV, special Characters (ä,ö,ü) get lost.

My Test:

content of af file test.csv:
english, german
door, tür

Powershell:
PS C:\Test> $a= ipcsv .\text.csv
$a
english german
------- ------
door tr

If I use instead GET-CONTENT it works the right way:

Powershell:
PS C:\Test> $a= gc .\text.csv
PS C:\Test> $a
english, german
door, tür

I'd like to use IMPORT-CSV as it's more convenient.
Any Idea how to handle special characters?

Regards,
Christoph


My System SpecsSystem Spec
Old 05-30-2007   #2 (permalink)
/\/\o\/\/ [MVP]
Guest


 

RE: import-csv missing charakters

It will work if the format of the file is Unicode :

PoSH> Set-Content text.txt -Encoding Unicode @'
>> english, german
>> door, tür
>> '@
>>


PoSH> Import-Csv text.txt

english german
------- ------
door tür

but I think this should also be supported on ANSI and / or an -Encoding
parameter on Import-Csv should be provided

Greetings /\/\o\/\/
http:/thePowerShellGuy.com


"Christoph Jandek" wrote:

> Hello,
>
> Using the powershell cmdlet IMPORT-CSV, special Characters (ä,ö,ü) get lost.
>
> My Test:
>
> content of af file test.csv:
> english, german
> door, tür
>
> Powershell:
> PS C:\Test> $a= ipcsv .\text.csv
> $a
> english german
> ------- ------
> door tr
>
> If I use instead GET-CONTENT it works the right way:
>
> Powershell:
> PS C:\Test> $a= gc .\text.csv
> PS C:\Test> $a
> english, german
> door, tür
>
> I'd like to use IMPORT-CSV as it's more convenient.
> Any Idea how to handle special characters?
>
> Regards,
> Christoph
>

My System SpecsSystem Spec
Old 05-30-2007   #3 (permalink)
Christoph Jandek
Guest


 

RE: import-csv missing charakters

Thank you for the fast response.

It works fine with Unicode or UTF-8.
The errrors occur with an ASCII-File, which was created by an Exchange 5.5
export.

I can pipe the ASCII-File to an Unicode File for using IMPORT-CSV.
Or is there a better way, as GET-CONTENT works fine?

Regards,
Christoph



"/\/\o\/\/ [MVP]" wrote:

> It will work if the format of the file is Unicode :
>
> PoSH> Set-Content text.txt -Encoding Unicode @'
> >> english, german
> >> door, tür
> >> '@
> >>

>
> PoSH> Import-Csv text.txt
>
> english german
> ------- ------
> door tür
>
> but I think this should also be supported on ANSI and / or an -Encoding
> parameter on Import-Csv should be provided
>
> Greetings /\/\o\/\/
> http:/thePowerShellGuy.com
>
>
> "Christoph Jandek" wrote:
>
> > Hello,
> >
> > Using the powershell cmdlet IMPORT-CSV, special Characters (ä,ö,ü) get lost.
> >
> > My Test:
> >
> > content of af file test.csv:
> > english, german
> > door, tür
> >
> > Powershell:
> > PS C:\Test> $a= ipcsv .\text.csv
> > $a
> > english german
> > ------- ------
> > door tr
> >
> > If I use instead GET-CONTENT it works the right way:
> >
> > Powershell:
> > PS C:\Test> $a= gc .\text.csv
> > PS C:\Test> $a
> > english, german
> > door, tür
> >
> > I'd like to use IMPORT-CSV as it's more convenient.
> > Any Idea how to handle special characters?
> >
> > Regards,
> > Christoph
> >

My System SpecsSystem Spec
Old 05-30-2007   #4 (permalink)
William Stacey [C# MVP]
Guest


 

Re: import-csv missing charakters

get-content defaults to reading in utf8 encoding, hence why it works.
import-csv, for some unknown reason, is defaulting to ascii encoding. So
your workaround
cat test.csv > test2.csv # make utf8
should work until they fix import-csv.

--
William Stacey [C# MVP]
PowerLocker, PowerPad
www.powerlocker.com



"Christoph Jandek" <ChristophJandek@discussions.microsoft.com> wrote in
message news:45FED266-2CDF-4191-B854-4945B52DFE02@microsoft.com...
| Thank you for the fast response.
|
| It works fine with Unicode or UTF-8.
| The errrors occur with an ASCII-File, which was created by an Exchange 5.5
| export.
|
| I can pipe the ASCII-File to an Unicode File for using IMPORT-CSV.
| Or is there a better way, as GET-CONTENT works fine?
|
| Regards,
| Christoph
|
|
|
| "/\/\o\/\/ [MVP]" wrote:
|
| > It will work if the format of the file is Unicode :
| >
| > PoSH> Set-Content text.txt -Encoding Unicode @'
| > >> english, german
| > >> door, tür
| > >> '@
| > >>
| >
| > PoSH> Import-Csv text.txt
| >
| > english
german
|
------
| > door
tür
| >
| > but I think this should also be supported on ANSI and / or an -Encoding
| > parameter on Import-Csv should be provided
| >
| > Greetings /\/\o\/\/
| > http:/thePowerShellGuy.com
| >
| >
| > "Christoph Jandek" wrote:
| >
| > > Hello,
| > >
| > > Using the powershell cmdlet IMPORT-CSV, special Characters (ä,ö,ü) get
lost.
| > >
| > > My Test:
| > >
| > > content of af file test.csv:
| > > english, german
| > > door, tür
| > >
| > > Powershell:
| > > PS C:\Test> $a= ipcsv .\text.csv
| > > $a
| > > english german
| > > ------- ------
| > > door tr
| > >
| > > If I use instead GET-CONTENT it works the right way:
| > >
| > > Powershell:
| > > PS C:\Test> $a= gc .\text.csv
| > > PS C:\Test> $a
| > > english, german
| > > door, tür
| > >
| > > I'd like to use IMPORT-CSV as it's more convenient.
| > > Any Idea how to handle special characters?
| > >
| > > Regards,
| > > Christoph
| > >


My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't Import deedee Vista mail 0 09-01-2008 12:30 PM
IMPORT FROM WM TO WLM Lindsay Graham Live Mail 4 03-18-2008 12:29 AM
Missing Drivers That Aren't Really Missing Bad Santa Drivers 4 11-04-2007 07:22 AM
Movie Maker - Missing Photos not missing Links =?Utf-8?B?TWVs?= Vista General 0 08-14-2006 11:23 AM
Import-Csv THG PowerShell 2 07-02-2006 02:43 PM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51