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
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
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.
add a comment |
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
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 forproduct9uses commas as delimiter where the other lines use something else. Product9 ends up as a single value for theproductNumbercolumn 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 youExport-Csvthe values are all duoble quoted, what may explain the last Row.
– LotPings
Mar 21 at 18:06
add a comment |
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
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
powershell
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.
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 forproduct9uses commas as delimiter where the other lines use something else. Product9 ends up as a single value for theproductNumbercolumn 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 youExport-Csvthe values are all duoble quoted, what may explain the last Row.
– LotPings
Mar 21 at 18:06
add a comment |
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 forproduct9uses commas as delimiter where the other lines use something else. Product9 ends up as a single value for theproductNumbercolumn 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 youExport-Csvthe 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
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
answered Mar 21 at 8:57
f6a4f6a4
433410
433410
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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
product9uses commas as delimiter where the other lines use something else. Product9 ends up as a single value for theproductNumbercolumn 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-Csvthe values are all duoble quoted, what may explain the last Row.– LotPings
Mar 21 at 18:06