Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 106361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:35:05+00:00 2026-05-11T01:35:05+00:00

When importing numbers from a csv file, I need to convert them to floats

  • 0

When importing numbers from a csv file, I need to convert them to floats with unit.

Currently I do this with an inline function:

data |> List.map float |> List.map (fun n -> n * 1.0<m>) 

But I’m wondering if there is a more elegant way to do this – or do I have to create my own ‘units’ module with conversion functions?

What would be really nice would be something like this, but I doubt it’s possible…

data |> List.map float |> List.map lift<m> 

This is the opposite of my previous question (How to generically remove F# Units of measure).

UPDATE: For homemade units, I’ve tried this, which works ok:

[<Measure>] type km =      static member lift (v:float) = v * 1.0<km>  data |> List.map float |> List.map km.lift 

or, following the question in this answer

data |> List.map (float >> km.lift) 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T01:35:05+00:00Added an answer on May 11, 2026 at 1:35 am

    It looks like units of measure can’t be type parameters for the moment (no idea if this will change). So the shortest way to write this is:

    data |> List.map float |> List.map ((*) 1.0<m>) 

    EDIT

    See also now FloatWithMeasure here

    http://msdn.microsoft.com/en-us/library/ee806527(VS.100).aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm importing some data from a CSV file, and numbers that are larger than
I'm importing from a CSV and getting data roughly in the format { 'Field1'
I'm importing some data from a CSV into Mathematica. The first few lines of
I am importing approx 350,000 lines from a CSV file into MySQL using PHP
I am importing data from a flat file into a normalized table structure. I
I want to use mysql LOAD DATA to import CSV file. Numbers in my
I am using a bulk insert to import data from a CSV file. One
We are importing from CSV to SQL. To do so, we are reading the
I am coding a survey that outputs a .csv file. Within this csv I
I have this large (and oddly formatted txt file) from the USDA's website. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.