CSV file, change cell valueAdd new line to the end of CSV with PowerShellMaximum size of csv file that can be processed using Import-CsvParsing imported CSVExport Powershell output to CSVPowershell Include data from import-csv in export-csvcleanup improperly formatted csv fileCSV value being overwrittenChanging the Delimiter in a large CSV file using PowershellExporting array results to csv using powershellComparing cells in two CSV files using powershellCSV Dynamic Unique Columns

Left multiplication is homeomorphism of topological groups

How to open new tab in existing terminal instead of new terminal instance?

How do I repair my stair bannister?

What would you call a finite collection of unordered objects that are not necessarily distinct?

Perfect riffle shuffles

A social experiment. What is the worst that can happen?

How did Monica know how to operate Carol's "designer"?

What will be the benefits of Brexit?

Freedom of speech and where it applies

Why isn't KTEX's runway designation 10/28 instead of 9/27?

Blender - show edges angles “direction”

Greatest common substring

Did US corporations pay demonstrators in the German demonstrations against article 13?

Is there any significance to the Valyrian Stone vault door of Qarth?

The most efficient algorithm to find all possible integer pairs which sum to a given integer

Why does this part of the Space Shuttle launch pad seem to be floating in air?

What if somebody invests in my application?

Bob has never been a M before

Is there a word to describe the feeling of being transfixed out of horror?

Is there an wasy way to program in Tikz something like the one in the image?

Music terminology - why are seven letters used to name scale tones

Can somebody explain Brexit in a few child-proof sentences?

Why are all the doors on Ferenginar (the Ferengi home world) far shorter than the average Ferengi?

Is it okay / does it make sense for another player to join a running game of Munchkin?



CSV file, change cell value


Add new line to the end of CSV with PowerShellMaximum size of csv file that can be processed using Import-CsvParsing imported CSVExport Powershell output to CSVPowershell Include data from import-csv in export-csvcleanup improperly formatted csv fileCSV value being overwrittenChanging the Delimiter in a large CSV file using PowershellExporting array results to csv using powershellComparing cells in two CSV files using powershellCSV Dynamic Unique Columns













0















https://i.stack.imgur.com/IjGvZ.png



productNumber productName active description
------------- ----------- ------ -----------
productNumber productName active description
1A100110001 product1 TRUE laptop
1A100110002 product2 TRUE laptop
1A100110003 product3 TRUE laptop
1A100110004 product4 TRUE laptop
1A100110005 product5 TRUE laptop
1A100110006 product6 TRUE laptop
1A100110007 product7 TRUE laptop
1A100110008 product8 TRUE laptop
1A100110009,product9,FALSE,PC


I would like to change the value of the productName (product2) to (product fortnox 2)



I tried the following code but it didin't work:



$products_fortnox = import-csv -Path .products_Fortnox_output.csv 
$products_fortnox | %

if ($_.productNumber -eq "1A100110002")

$_.productName = 'product fortnox 2'



$products_fortnox | export-csv .products_Fortnox_output.csv -NoTypeInformation









share|improve this question









New contributor




Biba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 2





    the code looks good...the issue is with ur csv file...it looks like there are 2 header rows...also the csv may not be a well-formed

    – Kiran
    Mar 21 at 8:31











  • so you mean that the problem with the csv file?

    – Biba
    Mar 21 at 8:51











  • Check your CSV. Looks like the line for product9 uses commas as delimiter where the other lines use something else. Product9 ends up as a single value for the productNumber column now.

    – Theo
    Mar 21 at 14:43











  • Please don't post picture representation of your data (also in your previous question) either post the real csv file or the Object after Importing as text. Once you Export-Csv the values are all duoble quoted, what may explain the last Row.

    – LotPings
    Mar 21 at 18:06















0















https://i.stack.imgur.com/IjGvZ.png



productNumber productName active description
------------- ----------- ------ -----------
productNumber productName active description
1A100110001 product1 TRUE laptop
1A100110002 product2 TRUE laptop
1A100110003 product3 TRUE laptop
1A100110004 product4 TRUE laptop
1A100110005 product5 TRUE laptop
1A100110006 product6 TRUE laptop
1A100110007 product7 TRUE laptop
1A100110008 product8 TRUE laptop
1A100110009,product9,FALSE,PC


I would like to change the value of the productName (product2) to (product fortnox 2)



I tried the following code but it didin't work:



$products_fortnox = import-csv -Path .products_Fortnox_output.csv 
$products_fortnox | %

if ($_.productNumber -eq "1A100110002")

$_.productName = 'product fortnox 2'



$products_fortnox | export-csv .products_Fortnox_output.csv -NoTypeInformation









share|improve this question









New contributor




Biba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 2





    the code looks good...the issue is with ur csv file...it looks like there are 2 header rows...also the csv may not be a well-formed

    – Kiran
    Mar 21 at 8:31











  • so you mean that the problem with the csv file?

    – Biba
    Mar 21 at 8:51











  • Check your CSV. Looks like the line for product9 uses commas as delimiter where the other lines use something else. Product9 ends up as a single value for the productNumber column now.

    – Theo
    Mar 21 at 14:43











  • Please don't post picture representation of your data (also in your previous question) either post the real csv file or the Object after Importing as text. Once you Export-Csv the values are all duoble quoted, what may explain the last Row.

    – LotPings
    Mar 21 at 18:06













0












0








0








https://i.stack.imgur.com/IjGvZ.png



productNumber productName active description
------------- ----------- ------ -----------
productNumber productName active description
1A100110001 product1 TRUE laptop
1A100110002 product2 TRUE laptop
1A100110003 product3 TRUE laptop
1A100110004 product4 TRUE laptop
1A100110005 product5 TRUE laptop
1A100110006 product6 TRUE laptop
1A100110007 product7 TRUE laptop
1A100110008 product8 TRUE laptop
1A100110009,product9,FALSE,PC


I would like to change the value of the productName (product2) to (product fortnox 2)



I tried the following code but it didin't work:



$products_fortnox = import-csv -Path .products_Fortnox_output.csv 
$products_fortnox | %

if ($_.productNumber -eq "1A100110002")

$_.productName = 'product fortnox 2'



$products_fortnox | export-csv .products_Fortnox_output.csv -NoTypeInformation









share|improve this question









New contributor




Biba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












https://i.stack.imgur.com/IjGvZ.png



productNumber productName active description
------------- ----------- ------ -----------
productNumber productName active description
1A100110001 product1 TRUE laptop
1A100110002 product2 TRUE laptop
1A100110003 product3 TRUE laptop
1A100110004 product4 TRUE laptop
1A100110005 product5 TRUE laptop
1A100110006 product6 TRUE laptop
1A100110007 product7 TRUE laptop
1A100110008 product8 TRUE laptop
1A100110009,product9,FALSE,PC


I would like to change the value of the productName (product2) to (product fortnox 2)



I tried the following code but it didin't work:



$products_fortnox = import-csv -Path .products_Fortnox_output.csv 
$products_fortnox | %

if ($_.productNumber -eq "1A100110002")

$_.productName = 'product fortnox 2'



$products_fortnox | export-csv .products_Fortnox_output.csv -NoTypeInformation






powershell






share|improve this question









New contributor




Biba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Biba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Mar 21 at 18:09









LotPings

19.9k61633




19.9k61633






New contributor




Biba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Mar 21 at 8:11









BibaBiba

11




11




New contributor




Biba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Biba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Biba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 2





    the code looks good...the issue is with ur csv file...it looks like there are 2 header rows...also the csv may not be a well-formed

    – Kiran
    Mar 21 at 8:31











  • so you mean that the problem with the csv file?

    – Biba
    Mar 21 at 8:51











  • Check your CSV. Looks like the line for product9 uses commas as delimiter where the other lines use something else. Product9 ends up as a single value for the productNumber column now.

    – Theo
    Mar 21 at 14:43











  • Please don't post picture representation of your data (also in your previous question) either post the real csv file or the Object after Importing as text. Once you Export-Csv the values are all duoble quoted, what may explain the last Row.

    – LotPings
    Mar 21 at 18:06












  • 2





    the code looks good...the issue is with ur csv file...it looks like there are 2 header rows...also the csv may not be a well-formed

    – Kiran
    Mar 21 at 8:31











  • so you mean that the problem with the csv file?

    – Biba
    Mar 21 at 8:51











  • Check your CSV. Looks like the line for product9 uses commas as delimiter where the other lines use something else. Product9 ends up as a single value for the productNumber column now.

    – Theo
    Mar 21 at 14:43











  • Please don't post picture representation of your data (also in your previous question) either post the real csv file or the Object after Importing as text. Once you Export-Csv the values are all duoble quoted, what may explain the last Row.

    – LotPings
    Mar 21 at 18:06







2




2





the code looks good...the issue is with ur csv file...it looks like there are 2 header rows...also the csv may not be a well-formed

– Kiran
Mar 21 at 8:31





the code looks good...the issue is with ur csv file...it looks like there are 2 header rows...also the csv may not be a well-formed

– Kiran
Mar 21 at 8:31













so you mean that the problem with the csv file?

– Biba
Mar 21 at 8:51





so you mean that the problem with the csv file?

– Biba
Mar 21 at 8:51













Check your CSV. Looks like the line for product9 uses commas as delimiter where the other lines use something else. Product9 ends up as a single value for the productNumber column now.

– Theo
Mar 21 at 14:43





Check your CSV. Looks like the line for product9 uses commas as delimiter where the other lines use something else. Product9 ends up as a single value for the productNumber column now.

– Theo
Mar 21 at 14:43













Please don't post picture representation of your data (also in your previous question) either post the real csv file or the Object after Importing as text. Once you Export-Csv the values are all duoble quoted, what may explain the last Row.

– LotPings
Mar 21 at 18:06





Please don't post picture representation of your data (also in your previous question) either post the real csv file or the Object after Importing as text. Once you Export-Csv the values are all duoble quoted, what may explain the last Row.

– LotPings
Mar 21 at 18:06












1 Answer
1






active

oldest

votes


















0














Try this one:



$source = '.products_Fortnox_output.csv '
$dest = '.products_Fortnox_output_new.csv '

[IO.File]::ReadAllText($filepath) -replace '(?m)^(1A100110002,)(prod.*)(,.*)$', '$1product fortnox 2$3' | Out-File $dest





share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Biba is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55276098%2fcsv-file-change-cell-value%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Try this one:



    $source = '.products_Fortnox_output.csv '
    $dest = '.products_Fortnox_output_new.csv '

    [IO.File]::ReadAllText($filepath) -replace '(?m)^(1A100110002,)(prod.*)(,.*)$', '$1product fortnox 2$3' | Out-File $dest





    share|improve this answer



























      0














      Try this one:



      $source = '.products_Fortnox_output.csv '
      $dest = '.products_Fortnox_output_new.csv '

      [IO.File]::ReadAllText($filepath) -replace '(?m)^(1A100110002,)(prod.*)(,.*)$', '$1product fortnox 2$3' | Out-File $dest





      share|improve this answer

























        0












        0








        0







        Try this one:



        $source = '.products_Fortnox_output.csv '
        $dest = '.products_Fortnox_output_new.csv '

        [IO.File]::ReadAllText($filepath) -replace '(?m)^(1A100110002,)(prod.*)(,.*)$', '$1product fortnox 2$3' | Out-File $dest





        share|improve this answer













        Try this one:



        $source = '.products_Fortnox_output.csv '
        $dest = '.products_Fortnox_output_new.csv '

        [IO.File]::ReadAllText($filepath) -replace '(?m)^(1A100110002,)(prod.*)(,.*)$', '$1product fortnox 2$3' | Out-File $dest






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 21 at 8:57









        f6a4f6a4

        433410




        433410






















            Biba is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            Biba is a new contributor. Be nice, and check out our Code of Conduct.












            Biba is a new contributor. Be nice, and check out our Code of Conduct.











            Biba is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55276098%2fcsv-file-change-cell-value%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해