converting CSV comma to csv semi-column


  1.    08 May 2010 #1
    Teddy Guest

    converting CSV comma to csv semi-column


    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


      My System SpecsSystem Spec

  2.    08 May 2010 #2
    Marco Shaw [MVP] Guest

    Re: converting CSV comma to csv semi-column


    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
    >
    >
      My System SpecsSystem Spec

  3.    08 May 2010 #3
    Teddy Guest

    Re: converting CSV comma to csv semi-column



    "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

      My System SpecsSystem Spec

  4.    08 May 2010 #4
    Larry__Weiss Guest

    Re: converting CSV comma to csv semi-column


    On 5/8/2010 9:20 AM, Teddy wrote:

    > "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
    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
      My System SpecsSystem Spec

  5.    08 May 2010 #5
    Teddy Guest

    Re: converting CSV comma to csv semi-column



    >
    > 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
    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










      My System SpecsSystem Spec

  6.    08 May 2010 #6
    Larry__Weiss Guest

    Re: converting CSV comma to csv semi-column


    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
      My System SpecsSystem Spec

  7.    08 May 2010 #7
    Teddy Guest

    Re: converting CSV comma to csv semi-column



    "Larry__Weiss" <lfw@newsgroup> a écrit dans le message de
    news:%23K$%236Vt7KHA.420@newsgroup

    > 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
    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.




      My System SpecsSystem Spec

  8.    08 May 2010 #8
    Larry__Weiss Guest

    Re: converting CSV comma to csv semi-column


    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

      My System SpecsSystem Spec

  9.    08 May 2010 #9
    Teddy Guest

    Re: converting CSV comma to csv semi-column



    "Larry__Weiss" <lfw@newsgroup> a écrit dans le message de
    news:u7Egatt7KHA.720@newsgroup

    >
    > 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
    >
    thank you, I'll take a look.

    Teddy

      My System SpecsSystem Spec

  10.    09 May 2010 #10
    Teddy Guest

    Re: converting CSV comma to csv semi-column



    "Larry__Weiss" <lfw@newsgroup> a écrit dans le message de
    news:u7Egatt7KHA.720@newsgroup

    >
    > 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
    >
    Hi 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

      My System SpecsSystem Spec

Page 1 of 2 12 LastLast
converting CSV comma to csv semi-column

Similar Threads
Thread Forum
In Excel 2007, how do I add a column to the left of a column when there is only 3?
I hid all but three columns and if I right-click on column A to insert a column, it becomes column B and no column is to the left.
Software
Comma or point - powershell problem
Hi I've a little? problem with the following script: cls $logfile = "C:\Log\Logfile.csv" # LastBootUpTime get-wmiobject -class...
PowerShell
Re: Leading comma operator - What does it do, really?
Good question. I'm not aware of any definitive article. An easy way to see the difference: PS>(1,2)|get-member vs PS>,(1,2)|get-member In...
PowerShell
Re: Converting a Word doc to a multi-column Excel spreadsheet
"DD Pgh" <DD Pgh@xxxxxx> wrote in message news:5B71BC28-88FC-4743-8734-EC7A83EB2B28@xxxxxx I think it might be doable, but I don't understand why...
VB Script
Convert CSV semi-colone to comma separated
Hello I have a CSV File for import in AD firstname;lastname;street,description Max;Huber;Street 1;Max Huber, Street 1 >In the description,...
PowerShell
Search fails if Folder name has comma in it?
I had a problem today trying to do a search via file explorer against a folder that had a comma in name. I got message saying 'The specific path...
Vista file management
Escape comma in dos command from PS script
I'm trying to execute a sql BCP call from within a Powershell script and am running into a problem. The line of code looks like: bcp "SELECT *...
PowerShell

Our Sites
  • Ten Forums
  • Eight Forums
  • Seven Forums
  • Help Me Bake
  • Site Links
  • Contact Us
  • Privacy and Cookies
  • Old server
    About Us
    Windows Vista Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

    © Designer Media Ltd
    All times are GMT -5. The time now is 20:47.
    .