Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numbers aren't recognised as numbers #44

Open
simon-brooke opened this issue Mar 23, 2019 · 1 comment
Open

Numbers aren't recognised as numbers #44

simon-brooke opened this issue Mar 23, 2019 · 1 comment

Comments

@simon-brooke
Copy link

Given this input data row:

Aldershot;Leo Docherty;12;Hampshire;76205;26955;15477;3637;1796;1090;0;0;0

(from here)

I get this output:

["Aldershot" "Leo Docherty" "12" "Hampshire" "76205" "26955" "15477" "3637" "1796" "1090" "0" "0" "0"]

In other words, numbers are being recognised only as strings.

I wrote a wee function which sorts this:

(defn numbers-as-numbers
  "Return a list like the sequence `l`, but with all those elements
  which are string representations of numbers replaced with numbers."
  [l]
  (map #(if 
          (string? %) 
          (try 
            (let [n (read-string %)]
              (if (number? n) n %))
            (catch Exception e %))
          %) 
       l))

I'll try to do a pull request later today with this added in.

@randomizedthinking
Copy link

The parse-csv function is meant to return a vector of strings. It is a different game to convert some values to numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants