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 8289327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:29:03+00:00 2026-06-08T12:29:03+00:00

I use F# once every few months or so and in between it seems

  • 0

I use F# once every few months or so and in between it seems I forget everything, so I hope you’ll excuse my ignorance. My code below is pulling data from Yahoo. It’s a good example that represents what I need to do. The first row returned has the column headings. I need to take the data (the tail of the list) and insert it into the database. What’s the best way to generate an insert statement based on the column headings returned (the column headings match the database column names)?

In the example below dataWithHeaders.[0] will contain “Date,Open,High,Low,Close,Volume,Adj Close.” Should I just take that string and put brackets around the headings to create the insert? Then in insertData add the value as a parameter? Is there a more elegant solution?

let url = System.String.Format("http://ichart.finance.yahoo.com/table.csv?s={0}&g=d&ignore=.csv", "FB")

let splitLineIntoArray (line : string) = 
    line.Split(",".ToCharArray())

let insertData (data : string[]) =
    // insert data
    ()

let client = new WebClient()
let dataWithHeaders = 
    client.DownloadString(url).Split(Environment.NewLine.ToCharArray())

let data =
    dataWithHeaders
    |> Array.toList
    |> List.tail
    |> List.map(splitLineIntoArray)
    |> List.iter insertData
  • 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. Editorial Team
    Editorial Team
    2026-06-08T12:29:04+00:00Added an answer on June 8, 2026 at 12:29 pm

    If you’re loading the data into SQL Server you can use this excellent CSV reader (free) and the SqlBulkCopy class. It’s simple and efficient.

    let loadStockPrices ticker =
      use client = new WebClient()
      let url = sprintf "http://ichart.finance.yahoo.com/table.csv?s=%s&g=d&ignore=.csv" ticker
      use stringReader = new StringReader(client.DownloadString(url))
      use csvReader = new CsvReader(stringReader, hasHeaders=true)
      use con = new SqlConnection("<connection_string>")
      con.Open()
      use bulkCopy = new SqlBulkCopy(con, DestinationTableName="<destination_table>")
      bulkCopy.WriteToServer(csvReader)
    

    The destination table should have the same columns as the incoming data (OHLC, etc).

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

Sidebar

Related Questions

I'm trying to use jquery to switch between three images once you click on
Of what use is this API? I adopted it a few months ago with
Once I use visualTreeHelper.getchild to find a child object, how would I get the
Does anyone know how to turn off iPhone's GPS programmatically? Once I use the
I want to use this jQuery gallery more than once on my page: http://workshop.rs/2010/07/create-image-gallery-in-4-lines-of-jquery/
I'm trying to use a sound callback function to show a button once my
Here I use two images. when i click once on the Sort_down.png image then
I mostly use SlickEdit and eclipse while working on embedded systems. Once in a
The website I'm building has a few elements that are the same on every
Possible Duplicate: Locking main() thread Below you'll find my code, Main calls two threads,

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.