teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

4

誤字の修正

2020/02/09 08:13

投稿

scalabiginner
scalabiginner

スコア7

title CHANGED
File without changes
body CHANGED
@@ -50,10 +50,10 @@
50
50
  import java.io.PrintWriter
51
51
  // 郵便番号と住所の列のみ抽出
52
52
  def address_format(line : String, out : PrintWriter) = {
53
- val list = line split ','
53
+ val list = line split ',' //文章を,で分ける
54
54
  val zip = dropQuote(list(2))//郵便番号
55
55
  val address = dropQuote(list(6)) + dropQuote(list(7)) + dropQuote(list(8))//住所
56
- out.write("%s,%s\n" format (zip, address))
56
+ out.write("%s,%s\n" format (zip, address)) //住所と郵便番号を書き込む
57
57
  }
58
58
 
59
59
  def dropQuote(str : String) : String = {// 前後のダブルクォーテーションを除去

3

誤字の修正

2020/02/09 08:13

投稿

scalabiginner
scalabiginner

スコア7

title CHANGED
File without changes
body CHANGED
@@ -55,16 +55,13 @@
55
55
  val address = dropQuote(list(6)) + dropQuote(list(7)) + dropQuote(list(8))//住所
56
56
  out.write("%s,%s\n" format (zip, address))
57
57
  }
58
- // 前後のダブルクォーテーションを除去
58
+
59
- def dropQuote(str : String) : String = {
59
+ def dropQuote(str : String) : String = {// 前後のダブルクォーテーションを除去
60
60
  str drop 1 dropRight 1
61
61
  }
62
- // 入力ファイル
63
- val source = Source.fromFile("C:\Users\xxx\Documents\scala\s.txt", "utf8")
62
+ val source = Source.fromFile("C:\Users\xxx\Documents\scala\s.txt", "utf8")// 入力ファイル
64
- // 出力ファイル
65
- val out = new PrintWriter("C:\Users\xxx\Documents\scala\t.txt", "utf8")
63
+ val out = new PrintWriter("C:\Users\xxx\Documents\scala\t.txt", "utf8")// 出力ファイル
66
- // ファイルを読み込んでループ
67
- val lines = source.getLines
64
+ val lines = source.getLines// ファイルを読み込んでループ
68
65
  lines.foreach(line => address_format(line, out))
69
66
  source.close
70
67
  out.close

2

誤字の修正

2020/02/08 19:37

投稿

scalabiginner
scalabiginner

スコア7

title CHANGED
File without changes
body CHANGED
@@ -51,12 +51,8 @@
51
51
  // 郵便番号と住所の列のみ抽出
52
52
  def address_format(line : String, out : PrintWriter) = {
53
53
  val list = line split ','
54
-
55
- //郵便番号
56
- val zip = dropQuote(list(2))
54
+ val zip = dropQuote(list(2))//郵便番号
57
-
58
- //住所
59
- val address = dropQuote(list(6)) + dropQuote(list(7)) + dropQuote(list(8))
55
+ val address = dropQuote(list(6)) + dropQuote(list(7)) + dropQuote(list(8))//住所
60
56
  out.write("%s,%s\n" format (zip, address))
61
57
  }
62
58
  // 前後のダブルクォーテーションを除去

1

誤字の修正

2020/02/08 18:36

投稿

scalabiginner
scalabiginner

スコア7

title CHANGED
File without changes
body CHANGED
@@ -76,5 +76,4 @@
76
76
  s.txtの中身
77
77
  01101,"060 ","0600000","ホッカイドウ","サッポロシチュウオウク","イカニケイサイガナイバアイ","北海道","札幌市中央区","以下に掲載がない場合",0,0,0,0,0,0
78
78
  01101,"064 ","0640941","ホッカイドウ","サッポロシチュウオウク","アサヒガオカ","北海道","札幌市中央区","旭ケ丘",0,0,1,0,0,0
79
- 01101,"060 ","0600041","ホッカイドウ","サッポロシチュウオウク","オオドオリヒガシ","北海道","札幌市中央区","大通東",0,0,1,0,0,0
79
+ 01101,"060 ","0600041","ホッカイドウ","サッポロシチュウオウク","オオドオリヒガシ","北海道","札幌市中央区","大通東",0,0,1,0,0,0
80
- ...