CSV 缺失值
CSV missing values
我正在使用 openCSV 读取 csv 文件,以便为我的 android 应用增加自动完成功能。虽然 csv 中的大多数值都已成功读取并膨胀自动完成文本视图,但其中一些是 "missing." 例如,csv 值 "Los Angeles, CA ",LAX 不是程序未读取。
正在读取 CSV:
public void readCSV() throws IOException {
InputStream is = this.getAssets().open("airport-codes.csv");
InputStreamReader ifr = new InputStreamReader(is, "UTF-8");
CSVReader reader = new CSVReader (ifr);
ArrayList<String> srd = new ArrayList<>();
while ((reader.readNext()) != null)
{
nextLine = reader.readNext();
Log.i("ArrivalTest", nextLine[0] + "- " + nextLine[1]);
srd.add(nextLine[0] + " - " + nextLine[1]);
}
reader.close();
autoCompleteTextView = (AutoCompleteTextView)findViewById(R.id.originCityAutoComp1);
adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, srd);
autoCompleteTextView.setAdapter(adapter);
}
机场-codes.csv:
...
"Lorient, France ",LRT
"Los Angeles, CA ",LAX // Los Angles LAX is in csv file.
"Los Cabos, Mexico ",SJD
...
Logcat:
...
Longview, TX - GGG
Lonorore, Vanuatu - LNE
Lord Howe Island, NS, Australia - LDH
Lorient, France - LRT
Los Cabos, Mexico - SJD // Los Angles LAX is missing.
Losuia, Papua New Guinea - LSA
Lourdes/Tarbes, France - LDE
...
您的 while 循环正在从 CSV 文件中提取每行奇数数据并将其丢弃:)
试试这个:
while ((nextLine = reader.readNext()) != null)
{
Log.i("ArrivalTest", nextLine[0] + "- " + nextLine[1]);
srd.add(nextLine[0] + " - " + nextLine[1]);
}
我正在使用 openCSV 读取 csv 文件,以便为我的 android 应用增加自动完成功能。虽然 csv 中的大多数值都已成功读取并膨胀自动完成文本视图,但其中一些是 "missing." 例如,csv 值 "Los Angeles, CA ",LAX 不是程序未读取。
正在读取 CSV:
public void readCSV() throws IOException {
InputStream is = this.getAssets().open("airport-codes.csv");
InputStreamReader ifr = new InputStreamReader(is, "UTF-8");
CSVReader reader = new CSVReader (ifr);
ArrayList<String> srd = new ArrayList<>();
while ((reader.readNext()) != null)
{
nextLine = reader.readNext();
Log.i("ArrivalTest", nextLine[0] + "- " + nextLine[1]);
srd.add(nextLine[0] + " - " + nextLine[1]);
}
reader.close();
autoCompleteTextView = (AutoCompleteTextView)findViewById(R.id.originCityAutoComp1);
adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, srd);
autoCompleteTextView.setAdapter(adapter);
}
机场-codes.csv:
...
"Lorient, France ",LRT
"Los Angeles, CA ",LAX // Los Angles LAX is in csv file.
"Los Cabos, Mexico ",SJD
...
Logcat:
...
Longview, TX - GGG
Lonorore, Vanuatu - LNE
Lord Howe Island, NS, Australia - LDH
Lorient, France - LRT
Los Cabos, Mexico - SJD // Los Angles LAX is missing.
Losuia, Papua New Guinea - LSA
Lourdes/Tarbes, France - LDE
...
您的 while 循环正在从 CSV 文件中提取每行奇数数据并将其丢弃:)
试试这个:
while ((nextLine = reader.readNext()) != null)
{
Log.i("ArrivalTest", nextLine[0] + "- " + nextLine[1]);
srd.add(nextLine[0] + " - " + nextLine[1]);
}