初心者です。CSVファイルをマージしたいのですが上手くできません。
テキストファイルを読み込みのアクティビティを利用して文字列を取得し、そのあとCSVファイル①に②を書き込みたいです。書き込みだけならできるのですが下記が上手くできません。どのような式を書いたら良いのでしょうか。
テキストファイルを読み込みのアクティビティを利用し、代入アクティビティで必要データのみ抽出し①と②をマージしようと考えています。(文字列を追加書き込みアクティビティを使用)
■質問1
CSVファイル①には最後改行があるのですが、最後の改行を削除する式がわかりません。
項目行
XXX,XXX,XXX
XXX,XXX,XXX
← この最後の改行を削除したい(ファイルマージする際に不要な改行のため)
■質問2
CSVファイル①にCSVファイル②をマージしたいのですが、1行目は項目のため2行目からマージしたいです。その方法がわかりません。
項目行 ← 不要
XXX,XXX,XXX
XXX,XXX,XXX
@mikesan ,
Use this logic.
CSV1:
CSV2
Output:
Sample code:
Merge CSV.zip (3.4 KB)
Thanks,
Ashok :
Yoichi
(Yoichi)
June 25, 2024, 7:18am
3
こんにちは
質問1
TrimEnd メソッドを使用してみてくたさい。
yourString = yourString.TrimEnd
質問2
以下ポストが役に立つと思います
Hi,
Can you try the following steps?
Read whole data as string using Read Text File Activity.
Remove 1st row using Regex.Replace method (or Replace activity) (Pattern should be "^.*\n" )
Convert string to datatable using Generate DataTable activity.
Hope the following image helps you.
[img20201030-3]
Regards,
こんにちは。
TrimEndで希望する動きになりました。ありがとうございます!
1 Like
Thank you for your advice. I’m happy to see the reference image.
Could you please enter the formula on the right side of the Assign activity here?
Due to company regulations, I can’t download the Zip file.
Regards,
@mikesan ,
This is the code to remove empty rows from datatable.
dt1.AsEnumerable.where(Function(row) row.ItemArray.All(function(col) not string.IsNullOrEmpty(col.ToString))).CopyToDataTable
It’s same for bot assign activity just Datatable variable will change.
Thanks,
Ashok