HI !
I am trying to convert a csv file with comma to a csv file with
semi-column.
I tried import-csv, export-csv, convert from...
It didn't work. I don't understand. I'm an idiot !
What would be the best way ?
can you help me please?
thanks
HI !
I am trying to convert a csv file with comma to a csv file with
semi-column.
I tried import-csv, export-csv, convert from...
It didn't work. I don't understand. I'm an idiot !
What would be the best way ?
can you help me please?
thanks
You can only do this with PowerShell v2:
PS>import-csv input.csv|export-csv -delim ";" output.csv
PowerShell v1 doesn't support the -Delimiter parameter.
Marco
"Teddy" <noreply@newsgroup> wrote in message
news:4be52db9$0$15666$426a74cc@newsgroup
> HI !
>
> I am trying to convert a csv file with comma to a csv file with
> semi-column.
>
> I tried import-csv, export-csv, convert from...
>
> It didn't work. I don't understand. I'm an idiot !
>
> What would be the best way ?
>
> can you help me please?
>
> thanks
>
>
"Marco Shaw [MVP]" <marco.shaw@newsgroup_SPAMgmail.com> a écrit dans le message de
news:uX4K%23vp7KHA.5808@newsgroup
> You can only do this with PowerShell v2:
> PS>import-csv input.csv|export-csv -delim ";" output.csv
>
> PowerShell v1 doesn't support the -Delimiter parameter.
>
> Marco
thank you Marco, but it doesn't work too.
Import-Csv: Can not process argument, the argument value "name" is not
valid. Change the value of the argument "name" and rerun the operation. At
line: 1 Character: 11
+ import-csv <<<< input.csv|export-csv -delim ";" output.csv
+ CategoryInfo : InvalidArgument: ([Import-Csv],
PSArgumentExc
eption
+ FullyQualifiedErrorId :
Argument,Microsoft.PowerShell.Commands.ImportCsv
Command
where input.csv is real file I rename from excel csv one
I run powershell 2 under W7
On 5/8/2010 9:20 AM, Teddy wrote:Reading from
> "Marco Shaw [MVP]">
>> You can only do this with PowerShell v2:
>> PS>import-csv input.csv|export-csv -delim ";" output.csv
>> PowerShell v1 doesn't support the -Delimiter parameter.
>>
> thank you Marco, but it doesn't work too.
> Import-Csv: Can not process argument, the argument value "name" is not
> valid. Change the value of the argument "name" and rerun the operation.
> At line: 1 Character: 11
> + import-csv <<<< input.csv|export-csv -delim ";" output.csv
> + CategoryInfo : InvalidArgument: ([Import-Csv], PSArgumentExc
> eption
> + FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.ImportCsv
> Command
> where input.csv is real file I rename from excel csv one
> I run powershell 2 under W7
http://softwareblog.morlok.net/2009/...ort-csv-error/
I learn that the error you are getting is related to the content
of your file input.csv
Be sure that input.csv is a valid CSV formatted file.
That article states that even Excel can produce a CSV file that
causes this error.
- Larry
thank you Larry, I think it's right but ...
>
> Reading from
>
> http://softwareblog.morlok.net/2009/...ort-csv-error/
>
> I learn that the error you are getting is related to the content
> of your file input.csv
>
> Be sure that input.csv is a valid CSV formatted file.
>
> That article states that even Excel can produce a CSV file that
> causes this error.
>
> - Larry
I tried with an other file, now input.csv only contain :
test1,test2,test3,test4
when I run import-csv input.csv|export-csv -delim ";" output.csv
there is no more error, but output file is empty !!!
I am desapointed !
It's the 1st time I use powershell.
I tried :
PS C:\temp> $data = get-content input.csv
PS C:\temp> $p
PS C:\temp> $data
test1,test2,test3,test4
so input.csv is ok
On 5/8/2010 10:08 AM, Teddy wrote:For the simplest CSV files it turns out to be more complicated.>
>> Reading from
>> http://softwareblog.morlok.net/2009/...ort-csv-error/
>> I learn that the error you are getting is related to the content
>> of your file input.csv
>> Be sure that input.csv is a valid CSV formatted file.
>> That article states that even Excel can produce a CSV file that
>> causes this error.
>>
> thank you Larry, I think it's right but ...
> I tried with an other file, now input.csv only contain :
> test1,test2,test3,test4
> when I run import-csv input.csv|export-csv -delim ";" output.csv
> there is no more error, but output file is empty !!!
> I am desapointed !
> It's the 1st time I use powershell.
> I tried :
> PS C:\temp> $data = get-content input.csv
> PS C:\temp> $p
> PS C:\temp> $data
> test1,test2,test3,test4
> so input.csv is ok
>
You have to provide column header captions via a parameter.
And, if you wish to create a simple CSV as output you have to do
some post-processing.
With import.csv containing
test1,test2,test3,test4
Try these PowerShell commands
import-csv -header "col1","col2","col3","col4" input.csv |
export-csv -delimiter ';' output.csv
$a = (get-content output.csv)
$a[2..($a.count - 1)] | out-file -encoding ASCII output.csv
- Larry
"Larry__Weiss" <lfw@newsgroup> a écrit dans le message de
news:%23K$%236Vt7KHA.420@newsgroupthank you Larry, your PowerShell commands works well !!
> On 5/8/2010 10:08 AM, Teddy wrote:>>>
>>> Reading from
>>> http://softwareblog.morlok.net/2009/...ort-csv-error/
>>> I learn that the error you are getting is related to the content
>>> of your file input.csv
>>> Be sure that input.csv is a valid CSV formatted file.
>>> That article states that even Excel can produce a CSV file that
>>> causes this error.
>>>
>> thank you Larry, I think it's right but ...
>> I tried with an other file, now input.csv only contain :
>> test1,test2,test3,test4
>> when I run import-csv input.csv|export-csv -delim ";" output.csv
>> there is no more error, but output file is empty !!!
>> I am desapointed !
>> It's the 1st time I use powershell.
>> I tried :
>> PS C:\temp> $data = get-content input.csv
>> PS C:\temp> $p
>> PS C:\temp> $data
>> test1,test2,test3,test4
>> so input.csv is ok
>>
> For the simplest CSV files it turns out to be more complicated.
> You have to provide column header captions via a parameter.
> And, if you wish to create a simple CSV as output you have to do
> some post-processing.
>
> With import.csv containing
>
> test1,test2,test3,test4
>
> Try these PowerShell commands
>
> import-csv -header "col1","col2","col3","col4" input.csv |
> export-csv -delimiter ';' output.csv
> $a = (get-content output.csv)
> $a[2..($a.count - 1)] | out-file -encoding ASCII output.csv
>
> - Larry
Now, I should have to see what it is wrong with my real file exported by
excel. it doesn't work no more.
On 5/8/2010 1:09 PM, Teddy wrote:http://softwareblog.morlok.net/2009/...ort-csv-error/
> "Larry__Weiss">
>> For the simplest CSV files it turns out to be more complicated.
>> You have to provide column header captions via a parameter.
>> And, if you wish to create a simple CSV as output you have to do
>> some post-processing.
>> With import.csv containing
>> test1,test2,test3,test4
>> Try these PowerShell commands
>> import-csv -header "col1","col2","col3","col4" input.csv |
>> export-csv -delimiter ';' output.csv
>> $a = (get-content output.csv)
>> $a[2..($a.count - 1)] | out-file -encoding ASCII output.csv
>>
> thank you Larry, your PowerShell commands works well !!
> Now, I should have to see what it is wrong with my real file exported by
> excel. it doesn't work no more.
>
suggests it is usually some trailing (right-most) extraneous data.
- Larry
"Larry__Weiss" <lfw@newsgroup> a écrit dans le message de
news:u7Egatt7KHA.720@newsgroupthank you, I'll take a look.
>
> On 5/8/2010 1:09 PM, Teddy wrote:>
>> "Larry__Weiss">>
>>> For the simplest CSV files it turns out to be more complicated.
>>> You have to provide column header captions via a parameter.
>>> And, if you wish to create a simple CSV as output you have to do
>>> some post-processing.
>>> With import.csv containing
>>> test1,test2,test3,test4
>>> Try these PowerShell commands
>>> import-csv -header "col1","col2","col3","col4" input.csv |
>>> export-csv -delimiter ';' output.csv
>>> $a = (get-content output.csv)
>>> $a[2..($a.count - 1)] | out-file -encoding ASCII output.csv
> >>
>> thank you Larry, your PowerShell commands works well !!
>> Now, I should have to see what it is wrong with my real file exported by
>> excel. it doesn't work no more.
>>
> http://softwareblog.morlok.net/2009/...ort-csv-error/
>
> suggests it is usually some trailing (right-most) extraneous data.
>
> - Larry
>
Teddy
"Larry__Weiss" <lfw@newsgroup> a écrit dans le message de
news:u7Egatt7KHA.720@newsgroupHi Larry
>
> On 5/8/2010 1:09 PM, Teddy wrote:>
>> "Larry__Weiss">>
>>> For the simplest CSV files it turns out to be more complicated.
>>> You have to provide column header captions via a parameter.
>>> And, if you wish to create a simple CSV as output you have to do
>>> some post-processing.
>>> With import.csv containing
>>> test1,test2,test3,test4
>>> Try these PowerShell commands
>>> import-csv -header "col1","col2","col3","col4" input.csv |
>>> export-csv -delimiter ';' output.csv
>>> $a = (get-content output.csv)
>>> $a[2..($a.count - 1)] | out-file -encoding ASCII output.csv
> >>
>> thank you Larry, your PowerShell commands works well !!
>> Now, I should have to see what it is wrong with my real file exported by
>> excel. it doesn't work no more.
>>
> http://softwareblog.morlok.net/2009/...ort-csv-error/
>
> suggests it is usually some trailing (right-most) extraneous data.
>
> - Larry
>
you are right !
The error I got is related to the empty value between commas !
no way to change this because the file is generate automaticaly with a
sofware under visual basic !
I tried to change "," to ";"
with Foreach{$_.Replace(",", ";")}
but when there is a value like "125,10" the result is "125;10"
in France, "," is the separate for decimal instead of point so we write
125,10 instead of 125.10
thank you
Teddy
| Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Re: Leading comma operator - What does it do, really? | Marco Shaw [MVP] | PowerShell | 3 | 15 Sep 2009 |
| Re: Converting a Word doc to a multi-column Excel spreadsheet | Paul Randall | VB Script | 1 | 12 Jan 2009 |
| Convert CSV semi-colone to comma separated | Gregor | PowerShell | 3 | 10 Apr 2008 |
| semi-locked | Greg | Vista General | 3 | 29 Jan 2008 |
| do something for each token in a line separated by comma | MaxMad | PowerShell | 5 | 09 Jan 2008 |