Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
7
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

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

はじめに

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

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: ファイルの結合

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
7
Help us understand the problem. What are the problem?