8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Powershellで複数のCSVファイルを読み込んでSortして出力

Posted at

##はじめに
前回作った歩引行と実際の売上のデータ行を合成して出力します。

sales.csv
id,detail_id,item,price,discount_per,discount_price
0,1,letsnote,2000,8,160
1,1,macbookair,1230,8,98.4
2,1,macbookpro,998,8,79.84
discounts.csv
"id","detail_id","item","price","discount_per","discount_price"
"0","998","8%","-160","8","160"
"1","998","8%","-98.4","8","98.4"
"2","998","8%","-79.84","8","79.84"
2つのCSVファイルを読み込んで結合して出力
PS >$sales=Import-Csv -path sales.csv,discounts.csv
PS >$sales=$sales | sort id,detail_id
PS >$sales | Export-Csv -path sales.csv
sales.csv
"id","detail_id","item","price","discount_per","discount_price"
"0","1","letsnote","2000","8","160"
"0","998","8%","-160","8","160"
"1","1","macbookair","1230","8","98.4"
"1","998","8%","-98.4","8","98.4"
"2","1","macbookpro","998","8","79.84"
"2","998","8%","-79.84","8","79.84"

##参考サイト

第2回チキチキ!シェル芸人養成勉強会をPowerShellでやってみた
の問題10: ファイルの結合

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?