Created
November 26, 2012 20:26
-
-
Save fayimora/4150412 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.fayi.ftp | |
object CSVParser { | |
val ADDRESS = "ftp://mirrors.kernel.org/gnu/README.DESCRIPTIONS" | |
val ADDRESS2 = "ftp://ftp.gnu.org/README" | |
//val ADDRESS2 = "ftp://username:[email protected]/README" | |
def main(args: Array[String]) { | |
//val remotecontents = io.Source.fromURL(ADDRESS2).getLines.toList | |
val localContents1 = io.Source.fromFile("file1.csv").getLines.toList | |
val localContents2 = io.Source.fromFile("file2.csv").getLines.toList | |
val headers1 = localContents1.head.split(", +").toList | |
val headers2 = localContents2.head.split(", +").toList | |
val rows1 = localContents1.drop(1).map(x => x.split(", +").toList) | |
val rows2 = localContents2.drop(1).map(x => x.split(", +").toList) | |
//val map = headers1.zipWithIndex.toMap.mapValues(n => rows1.map(_(n))) | |
//val map = headers1 zip rows1.transpose | |
val map = headers1.zip(rows1.transpose).toMap | |
println(map.foreach(println)) | |
} | |
} | |
//class Report(var name: String, var date: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id | fname | lname | dob | city | |
---|---|---|---|---|---|
1 | fayi | femi | 03071993 | London | |
2 | buyi | femi | 01061995 | London | |
3 | wene | etitinwo | 15011993 | London | |
4 | toyi | femi | 30051998 | London |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment