Add data to csv column based on row value

Grady D

I have a CSV that I read in. The problem is that this CSV as columns that are not filled with data. I need to go through a column and when the ID number matches the ID of the content I want to add, add in the data. Currently I have,

$counter = 0
foreach($invoice in $allInvoices){
  $knownName += $info | where-Object{$_.'DOCNUMBR'.trim().contains($cleanInvNum)}
  $DocNumbr = $info | where-Object{$_.'DOCNUMBR'.trim() -eq $cleanInvNum}
  $output = $ResultsTable.Rows.Add(" ", " ", " ", " ", $DocNumbr[$counter].'ORG', $DocNumbr[$counter].'CURNT', $knownName[$counter].'DOCNUMBR', " ")
  $counter++
}

The problem with this code is that it just adds rows under the CSV and does not add the data to the row. How can I do a statement where I find ID and add the above content into that row?

Grady D

I was able to resolve my issue by reworking my foreach loop and setting the values directly like so,

$output.'CheckNumber' = $DocNumbr.'ORTRXAMT'
$output.'CheckDate' = $DocNumbr.'CURTRXAM'
$output.'Invoice Number' = $knownName.'DOCNUMBR'

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Add column to data frame based on values of another column in another row

From Dev

R add index column to data frame based on row values

From Dev

R add index column to data frame based on row values

From Dev

Dplyr add column to data frame based on specific value of grouped data

From Dev

Return row of Data Frame based on value in a column - R

From Dev

Return row of Data Frame based on value in a column. R script

From Dev

Pandas Dataframe Add a value to a new Column based on the previous row limited to the maximum value in that column

From Dev

Split a row based on a column value

From Dev

Duplicate row based in column value

From Dev

Add rows based on a column value

From Dev

How to add data from column in a data frame to a corpus based on a value from another column in R?

From Dev

Pandas - conditionally select source column of data for a new column based on row value

From Dev

R - Join on data.table, selecting a different column based on value of another column in row

From Dev

Add new column to each row of a .csv in ruby

From Dev

R: add matrices based on row and column names

From Dev

pig to add column based on value in another column

From Dev

pandas add column to dataframe having the value from another row based on condition

From Dev

For every row how to add a class name on the <th> based on the value on a particular column using Datatables

From Dev

CSV - How to add columns based on an existing column?

From Java

Deleting DataFrame row in Pandas based on column value

From Dev

delete row/entry based on duplicate column value

From Dev

Kendo Grid Row Colors based on value of column

From Dev

Duplicate row based on value in different column

From Dev

Color table row based on column value

From Dev

How to duplicate a row based on column or cell value

From Dev

Indexing Row Values Based on Value of Each Column

From Dev

Get column header based on a value in each row

From Dev

JDBC Discover row based on a value in column

From Dev

Access a row from a df based on a column value

Related Related

  1. 1

    Add column to data frame based on values of another column in another row

  2. 2

    R add index column to data frame based on row values

  3. 3

    R add index column to data frame based on row values

  4. 4

    Dplyr add column to data frame based on specific value of grouped data

  5. 5

    Return row of Data Frame based on value in a column - R

  6. 6

    Return row of Data Frame based on value in a column. R script

  7. 7

    Pandas Dataframe Add a value to a new Column based on the previous row limited to the maximum value in that column

  8. 8

    Split a row based on a column value

  9. 9

    Duplicate row based in column value

  10. 10

    Add rows based on a column value

  11. 11

    How to add data from column in a data frame to a corpus based on a value from another column in R?

  12. 12

    Pandas - conditionally select source column of data for a new column based on row value

  13. 13

    R - Join on data.table, selecting a different column based on value of another column in row

  14. 14

    Add new column to each row of a .csv in ruby

  15. 15

    R: add matrices based on row and column names

  16. 16

    pig to add column based on value in another column

  17. 17

    pandas add column to dataframe having the value from another row based on condition

  18. 18

    For every row how to add a class name on the <th> based on the value on a particular column using Datatables

  19. 19

    CSV - How to add columns based on an existing column?

  20. 20

    Deleting DataFrame row in Pandas based on column value

  21. 21

    delete row/entry based on duplicate column value

  22. 22

    Kendo Grid Row Colors based on value of column

  23. 23

    Duplicate row based on value in different column

  24. 24

    Color table row based on column value

  25. 25

    How to duplicate a row based on column or cell value

  26. 26

    Indexing Row Values Based on Value of Each Column

  27. 27

    Get column header based on a value in each row

  28. 28

    JDBC Discover row based on a value in column

  29. 29

    Access a row from a df based on a column value

HotTag

Archive