私はIMDBからTSVにしようとしていますの解析:タブ区切りファイル
$hutter Battle of the Sexes (2017) (as $hutter Boy) [Bobby Riggs Fan] <10>
NVTION: The Star Nation Rapumentary (2016) (as $hutter Boy) [Himself] <1>
Secret in Their Eyes (2015) (uncredited) [2002 Dodger Fan]
Steve Jobs (2015) (uncredited) [1988 Opera House Patron]
Straight Outta Compton (2015) (uncredited) [Club Patron/Dopeman]
$lim, Bee Moe Fatherhood 101 (2013) (as Brandon Moore) [Himself - President, Passages]
For Thy Love 2 (2009) [Thug 1]
Night of the Jackals (2009) (V) [Trooth]
"Idle Talk" (2013) (as Brandon Moore) [Himself]
"Idle Times" (2012) {(#1.1)} (as Brandon Moore) [Detective Ryan Turner]
あなたには、いくつかの行はタブで開始することができ、いくつかがないので
。私は俳優の名前をキーとし、値の映画のリストを持つ地図が必要です。俳優の名前の間には、映画のリストが表示されるまでの1つ以上のタブがあります。
マイコード:
while ((line = reader.readLine()) != null) {
Matcher matcher = headerPattern.matcher(line);
boolean headerMatchFound = matcher.matches();
if (headerMatchFound) {
Logger.getLogger(ActorListParser.class.getName()).log(Level.INFO, "Header for actor list found");
String newline;
reader.readLine();
while ((newline = reader.readLine()) != null) {
String[] fullLine = null;
String actor;
String title;
Pattern startsWithTab = Pattern.compile("^\t.*");
Matcher tab = startsWithTab.matcher(newline);
boolean tabStartMatcher = tab.matches();
if (!tabStartMatcher) {
fullLine = newline.split("\t.*");
System.out.println("Actor: " + fullLine[0] +
"Movie: " + fullLine[1]);
}//this line will have code to match lines that start with tabs.
}
}
}
私が取得し、arrayoutofbounds
例外の前に、私は数行のためにこれだけ作品をやった方法。 1つ以上のタブがある場合、どのようにして行を解析し、最大で2つの文字列に分割できますか?
データリストをスクリーンショットとして投稿しないでください。データをコピー/ペーストし、固定幅フォーマット用に4つのスペースをインデントします。 –
データリストの問題は実際にSOのルールですか?データを貼り付けるのは面倒で、修正するのに時間がかかります。 – user465001
非常に強くお勧めします。あなたは、フルスクリーンではなく、あなたの質問を伝えるのに十分な数行のデータを表示すればよい。画像は本当に画像であるもののためにのみ予約する必要があります。それがテキストの場合、テキストとしてポストに属します。 –