Help us understand the problem. What is going on with this article?

CSVファイルを1行づつの読み込みます

More than 3 years have passed since last update.

CSVのファイルをShift-JISで読み込みます。
今回の読み込み方法はStreamReaderを使って読み込みたいと思います。。
StreamReaderは特定のエンコードで文字を入力する際に使用します。
文字コードはCSVのためshit-JISになります。

StreamReader csvText = new StreamReader(csvPath, 
Encoding.GetEncoding("Shift-JIS")); //文字コードを設定してCSVファイルの読み込み
ArrayList lineCsv = new ArrayList();
string csvTextLine = csvText.ReadLine();
while (csvTextLine != null)
{
lineCsv.Add(csvTextLine);
csvTextLine = csvText.ReadLine();
}

ArrayListで動的な配列を行います。
ReadLineでテキストの1行づつ読み込みます。
それぞれを、再度配列"csvTextLine"に追加していきます。
そして、さらに動的な配列lineCsvに加えて行きます。

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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした