This file contains hidden or 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
| # parse csv files to an awk array. | |
| awk -F, '{ | |
| parse_csv(r); | |
| # replace following line with your code. | |
| print r[1], r[2], r[3], r[4]; | |
| } function parse_csv(r, _quote, _i, _n) { | |
| _i = 1; | |
| _quote = 0; # in a quoted string or not. |
This file contains hidden or 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
| grep 'DEPOSIT' sample.bankstmt.csv | cut -d ',' -f4 | awk '{s+=$1} END {print s}' | |
| //produces correct output by summing the numbers | |
| //951.95 |
This file contains hidden or 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
| #!/usr/bin/awk -f | |
| ########################### AWK CSV Parser ########################### | |
| # # | |
| # ********** This file is in the public domain. ********** # | |
| # # | |
| # Use this source in any way you wish. # | |
| # Feedback and bug reports would be appreciated. # | |
| # As would a note about what how you are using it. # | |
| # # |
This file contains hidden or 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
| -- Kevin Cantu | |
| -- April 2012 | |
| import Control.Monad (when) | |
| import Data.Map (Map) | |
| import Data.List | |
| import Data.List.Split | |
| import qualified Data.Map as M | |
| import System.Environment | |
| import System.IO |
This file contains hidden or 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
| require 'csv' | |
| require 'time' | |
| FORMAT = "%Y-%m-%d %H:%M:%S %Z" | |
| CSV.foreach('times') do |row| | |
| begin | |
| start = DateTime.strptime(row[2].lstrip, FORMAT) | |
| stop = DateTime.strptime(row[3].lstrip, FORMAT) |
This file contains hidden or 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
| * Generic questions: | |
| - How does a CDN work? | |
| - Can you describe how DNS works? | |
| - Can you describe the difference between TCP and UDP? | |
| - What is the difference between /32 and 255.255.255.255, what notation is used in each case? |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
| import scala.util.parsing.json._ | |
| val result = JSON.parseFull(""" | |
| {"name": "Naoki", "lang": ["Java", "Scala"]} | |
| """) | |
| result match { | |
| case Some(e) => println(e) // => Map(name -> Naoki, lang -> List(Java, Scala)) | |
| case None => println("Failed.") | |
| } |
This file contains hidden or 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
| //------------------------------------------------------------------------------------------------- | |
| // This would be something equivalent to: | |
| // $ cat inputs.txt | fgrep -f includes.txt | fgrep -v -f excludes.txt | uniq | sort | |
| //------------------------------------------------------------------------------------------------- | |
| import scala.util.matching.Regex | |
| def grep(inputs: Seq[String], includes: Set[Regex], excludes: Set[Regex], sort: Boolean = false, uniq: Boolean = false): Iterable[String] = { | |
| def pass(s: String, set: Set[Regex]): Boolean = set.exists(r => r.findFirstIn(s).isDefined) | |
| val grep1: Iterable[String] = if(includes.size==0) inputs else for { c <- inputs if(pass(c, includes)) } yield { c } |
This file contains hidden or 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
| val filename = "data/wallet/wallet.sample.txt" | |
| val lines: java.util.List[String] = | |
| java.nio.file.Files.readAllLines( | |
| java.nio.file.Paths.get(filename), java.nio.charset.StandardCharsets.UTF_8) |