-
C#樹林
【C#】テキストファイルに行データを追記する (File.AppendAllLines)
既存のテキストファイルの末尾に、新しい行データを追加したい場合は System.IO.File.AppendAllLines メソッドを使用します。 このメソッドは、指定したファイルが存在しない場合は自動的に新規作成し、存在する場合は元のデータを消さずに、その続きから... -
C#樹林
[C#] Writing Array Data to a Text File (File.WriteAllLines)
To save a "string array" or "list" directly to a file, using the WriteAllLines method in the System.IO.File class is the most efficient way. By using this method, you do not need to write a loop with StreamWriter; you can complete the da... -
C#樹林
【C#】配列のデータをテキストファイルとして書き出す (File.WriteAllLines)
プログラム内で扱っている「文字列の配列」や「リスト」を、そのままファイルに保存したい場合、C# の System.IO.File クラスにある WriteAllLines メソッドを使うのが最もスマートです。 このメソッドを使えば、StreamWriter を使ってループ処理を書く必... -
C#樹林
[C#] Reading a Text File Line by Line (File.ReadLines)
There are several ways to read the contents of a text file. The File.ReadLines method is unique because it uses "lazy execution," which means it reads data bit by bit as needed. This makes it extremely memory-efficient when handling mass... -
C#樹林
【C#】テキストファイルを1行ずつ読み込む (File.ReadLines)
テキストファイルの中身を読む方法はいくつかありますが、File.ReadLines メソッドは**「必要な分だけ少しずつ読み込む(遅延実行)」**という特性を持っており、ログファイルのような巨大なファイルを扱う際や、先頭の数行だけを確認したい場合に非常にメ... -
C#樹林
[C#] How to Get Paths of Special Folders like Documents and Desktop (Environment.GetFolderPath)
It is not recommended to hardcode paths like C:\Users\Name\... because they vary by OS and user. Instead, use the Environment.GetFolderPath method and the Environment.SpecialFolder enum. This allows you to dynamically retrieve the correc... -
C#樹林
【C#】マイドキュメントやデスクトップなどの特殊フォルダのパスを取得する (Environment.GetFolderPath)
OSやユーザーごとに異なる「マイドキュメント」「デスクトップ」「AppData」などのパスをハードコーディング(C:\Users\Name\... と直接書くこと)するのは推奨されません。 代わりに Environment.GetFolderPath メソッドと Environment.SpecialFolder 列... -
C#樹林
[C#] Creating Temporary Files and Locating the Temp Folder (Path.GetTempFileName)
When you want to save temporary work data (such as cache, logs, or intermediate files during a download) while an application is running, it is common to use the system's standard "Temp" folder. By using the Path.GetTempFileName method, ... -
C#樹林
【C#】一時ファイルを作成する・一時フォルダの場所を取得する (Path.GetTempFileName)
アプリケーションの処理中に、作業用の一時データ(キャッシュやログ、ダウンロード中の中間ファイルなど)を保存したい場合、システム標準の「一時フォルダ(Temp)」を利用するのが一般的です。 Path.GetTempFileName メソッドを使用すると、一時フォル... -
C#樹林
[C#] How to Get and Change the Current Working Directory
To get the "Current Directory," which is the base directory where the program is currently running, use the Directory.GetCurrentDirectory method. This directory serves as the starting point when reading or writing files using relative pa... -
C#樹林
【C#】現在の作業ディレクトリ(カレントディレクトリ)を取得・変更する
プログラムが現在実行の基準としている「作業ディレクトリ(Current Directory)」を取得するには、Directory.GetCurrentDirectory メソッドを使用します。 相対パス(例:./data.txt)でファイルを読み書きする際、このカレントディレクトリが起点となり... -
C#樹林
[C#] How to Get a List of Subdirectories in a Directory (Directory.GetDirectories)
To find out what subfolders exist inside a specific folder, use the Directory.GetDirectories method. Similar to file searches, you can filter results using wildcards and choose whether to search through all levels of subfolders. Table of... -
C#樹林
【C#】指定したディレクトリにあるサブディレクトリ(フォルダ)一覧を取得する (Directory.GetDirectories)
指定したフォルダの中にどのようなサブフォルダが存在するかを調べるには、Directory.GetDirectories メソッドを使用します。 ファイル検索と同様に、ワイルドカードによるフィルタリングや、サブフォルダのさらに奥階層まで検索するかどうかを指定できま... -
C#樹林
[C#] Searching and Getting a List of Files in a Directory (Directory.GetFiles)
To get a list of file names in a specific folder, use the Directory.GetFiles method. This method allows you to filter files using "wildcards" for specific extensions or naming patterns. You can also search through subfolders by specifyin... -
C#樹林
【C#】指定したディレクトリにあるファイル一覧を検索・取得する (Directory.GetFiles)
特定のフォルダ内にあるファイル名の一覧を取得するには、Directory.GetFiles メソッドを使用します。 このメソッドでは、「ワイルドカード」を使用して特定の拡張子や名前のパターンを持つファイルだけをフィルタリングしたり、検索オプションを指定して... -
C#樹林
[C#] Creating, Deleting, and Moving Directories (Folders)
In addition to files, you can manage directories (folders) using the static methods of the System.IO.Directory class. In particular, the CreateDirectory method is very convenient because it automatically creates any missing parent folder... -
C#樹林
【C#】ディレクトリ(フォルダ)の作成・削除・移動を行う
ファイルだけでなく、ディレクトリ(フォルダ)自体の管理も System.IO.Directory クラスの静的メソッドで行います。 特に CreateDirectory メソッドは、指定したパスの途中にあるフォルダ(親フォルダ)が存在しない場合、それらも含めて一気に作成してく... -
C#樹林
[C#] How to Check and Change the “Read-Only” Attribute of a File (FileInfo.IsReadOnly)
This article explains how to set the "Read-Only" attribute via code for important configuration files or data that should not be accidentally overwritten or deleted. It also covers how to remove the attribute when you need to edit the fi... -
C#樹林
【C#】ファイルの「読み取り専用」属性を確認・変更する (FileInfo.IsReadOnly)
重要な設定ファイルや、誤って上書き・削除されたくないデータファイルに対して、プログラムから「読み取り専用(ReadOnly)」属性を付与したり、逆に編集するために属性を解除したりする方法について解説します。 C# では FileInfo クラスの IsReadOnly ... -
C#樹林
[C#] How to Get and Change File Creation and Update Times (FileInfo / File)
The "Last Write Time" (timestamp) of a file is essential for tasks like backup processing, automatically deleting old logs, or managing cache freshness. By using the System.IO.FileInfo class or the static methods of the File class, you c... -
C#樹林
【C#】ファイルの作成日時・更新日時を取得、変更する (FileInfo / File)
ファイルの「更新日時(タイムスタンプ)」は、バックアップ処理の判定や、古いログファイルの自動削除、キャッシュの鮮度管理などで重要な情報です。 System.IO.FileInfo クラス(または File クラスの静的メソッド)を使用することで、これらの日時情報... -
Python樹林
[Python] How to Cross-Tabulate and Aggregate Data with Pandas pivot_table
Summarizing Data with pivot_table Method The pivot_table method in Pandas allows you to organize large amounts of data and create cross-tabulations. Similar to the pivot table feature in Excel, it is a powerful tool for calculating avera... -
Python樹林
【Python】Pandasのpivot_tableでデータをクロス集計・集約する方法
pivot_tableメソッドによるデータの要約 Pandasの pivot_table メソッドを使用すると、大量のデータを特定の切り口で整理し、クロス集計を行うことができます。Excelのピボットテーブル機能と同様に、行と列を指定してデータの平均や合計を算出する際に非... -
Python樹林
How to Extract Data from Specific Levels of a MultiIndex in Python
Managing Hierarchical Data with MultiIndex In Pandas, you can use a "MultiIndex" to manage data with multiple levels of row indexes. This is very useful for organizing data with complex structures. For example, you can manage data with a... -
Python樹林
【Python】MultiIndex(マルチインデックス)の特定の階層データを抽出する方法
MultiIndexによる多階層データの管理 Pandasでは、行インデックスに複数の階層を持たせる「MultiIndex」を使用することで、複雑な構造を持つデータを効率的に整理できます。例えば、「支店名」とその下の「部署名」といった親子関係にあるデータを一つのデ... -
Python樹林
Sorting Data with the sort_values Method in Pandas
Basics of Sorting Data with the sort_values Method In a Pandas DataFrame, you can use the sort_values method to sort data based on specific column values. You can set detailed conditions, such as primary and secondary sort keys, by provi... -
Python樹林
【Python】Pandasで複数列を条件に指定してDataFrameをソートする方法
sort_valuesメソッドによるデータ並べ替えの基本 PandasのDataFrameにおいて、特定のカラムの値を基準にデータを並べ替えるには sort_values メソッドを使用します。単一の列だけでなく、複数の列をリスト形式で指定することで、第1優先、第2優先といった... -
Python樹林
[Python] How to Use groupby to Aggregate Statistics by Category in Pandas
Basics of Data Aggregation with GroupBy In data analysis, grouping data by specific attributes and checking their statistical values is a crucial task. Using the groupby method in the Pandas library, you can aggregate data just like the ... -
Python樹林
【Python】Pandasでカテゴリごとに統計値を集計するgroupbyの使い方
GroupByによるデータ集計の基本 データ分析において、特定の属性ごとにデータをグループ化し、それぞれの統計値を確認する作業は非常に重要です。Pandasライブラリの groupby メソッドを使用すると、SQLのGROUP BY句のようにデータをまとめ、平均や合計な... -
Python樹林
[Python] How to Extract (Filter) Data Matching Conditions in a Pandas DataFrame
Extracting specific rows that meet certain criteria from a Pandas DataFrame holding large amounts of data is one of the most critical steps in data analysis. Pandas uses a mechanism called "Boolean Indexing" to allow for intuitive data e...