Ruby
Python
JavaScript

Search for '{{search_term}}'

Exercise: Add numbers taken from a CSV file

CMOS is the Code-Maven Open Source podcast that also includes video interviews. Subscribe to this feed RSS feed with your Podcast listener app or via iTunes iTunes.

Exercise: Add numbers taken from a CSV file

See other exercises.

Given a CSV file like this:

examples/data/process_csv_file.csv

Tudor;Vidor;10;Hapci
Szundi;Morgo;7;Szende
Kuka;Hofeherke;100;Kiralyno
Boszorkany;Herceg;9;Meselo

Write a script that will take the values of the 3rd in this Comma Separated Values file and add them together.

Can your code also handle this file?

examples/data/distance.csv

Budapest,Bukarest,1200,km
Tel Aviv,Beirut,500,km
London,Dublin,300,km
New York,"Moscow, East",6000,km
Local,"Remote
Location",10,km

Tools

Solutions in Perl 5

Solution Ruby

Comments

In the comments, please wrap your code snippets within <pre> </pre> tags and use spaces for indentation.
comments powered by Disqus