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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:28:37+00:00 2026-06-18T05:28:37+00:00

I have a string that contains comma delimited text. The comma delimited text comes

  • 0

I have a string that contains comma delimited text. The comma delimited text comes from an excel .csv file so there are hundreds of rows of data that are seven columns wide. An example of a row from this file is:

2012-10-01,759.05,765,756.21,761.78,3168000,761.78

I want to search through the hundreds of rows by the date in the first column. Once I find the correct row I want to extract the number in the first position of the comma delimited string so in this case I want to extract the number 759.05 and assign it to variable “Open”.

My code so far is:

strURL = "http://ichart.yahoo.com/table.csv?s=" & tickerValue
strBuffer = RequestWebData(strURL)

Dim Year As String = 2012
Dim Quarter As String = Q4
If Quarter = "Q4" Then
    Dim Open As Integer =
End If

Once I can narrow it down to the right row I think something like row.Split(“,”)(1).Trim) might work.

I’ve done quite a bit of research but I can’t solve this on my own. Any suggestions!?!

ADDITIONAL INFORMATION:

Private Function RequestWebData(ByVal pstrURL As String) As String
    Dim objWReq As WebRequest
    Dim objWResp As WebResponse
    Dim strBuffer As String
    'Contact the website
    objWReq = HttpWebRequest.Create(pstrURL)
    objWResp = objWReq.GetResponse()
    'Read the answer from the Web site and store it into a stream
    Dim objSR As StreamReader
    objSR = New StreamReader(objWResp.GetResponseStream)
    strBuffer = objSR.ReadToEnd
    objSR.Close()

    objWResp.Close()

    Return strBuffer
End Function 

MORE ADDITIONAL INFORMATION:

A more complete picture of my code

Dim tickerArray() As String = {"GOOG", "V", "AAPL", "BBBY", "AMZN"}

For Each tickerValue In Form1.tickerArray

        Dim strURL As String
        Dim strBuffer As String
        'Creates the request URL for Yahoo
        strURL = "http://ichart.yahoo.com/table.csv?s=" & tickerValue

        strBuffer = RequestWebData(strURL)

        'Create Array
        Dim lines As Array = strBuffer.Split(New String() {Environment.NewLine}, StringSplitOptions.None)

        'Add Rows to DataTable
        dr = dt.NewRow()
        dr("Ticker") = tickerValue
        For Each columnQuarter As DataColumn In dt.Columns
            Dim s As String = columnQuarter.ColumnName
            If s.Contains("-") Then
                Dim words As String() = s.Split("-")
                Dim Year As String = words(0)
                Dim Quarter As String = words(1)
                Dim MyValue As String
                Dim Open As Integer
                If Quarter = "Q1" Then MyValue = Year & "-01-01"
                If Quarter = "Q2" Then MyValue = Year & "-04-01"
                If Quarter = "Q3" Then MyValue = Year & "-07-01"
                If Quarter = "Q4" Then MyValue = Year & "-10-01"
                For Each line In lines
                    Debug.WriteLine(line)
                    If line.Split(",")(0).Trim = MyValue Then Open = line.Split(",")(1).Trim
                    dr(columnQuarter) = Open
                Next
            End If

        Next
        dt.Rows.Add(dr)
    Next

Right now in the For Each line in lines loop, Debug.WriteLine(line) outputs 2,131 lines:

From

Date,Open,High,Low,Close,Volume,Adj Close
2013-02-05,761.13,771.11,759.47,765.74,1870700,765.74
2013-02-04,767.69,770.47,758.27,759.02,3040500,759.02
2013-02-01,758.20,776.60,758.10,775.60,3746100,775.60

All the way to…

2004-08-19,100.00,104.06,95.96,100.34,22351900,100.34

But, what I expect is for Debug.WriteLine(line) to output one line at a time in the For Each line in lines loop. So I would expect the first output to be Date,Open,High,Low,Close,Volume,Adj Close and the next output to be 2013-02-05,761.13,771.11,759.47,765.74,1870700,765.74. I expect this to happen 2,131 times until the last output is 2004-08-19,100.00,104.06,95.96,100.34,22351900,100.34

  • 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-18T05:28:38+00:00Added an answer on June 18, 2026 at 5:28 am

    You could loop through the lines and call String.Split to parse the columns in each line, for instance:

    Dim lines() As String = strBuffer.Split(New String() {Environment.NewLine}, StringSplitOptions.None)
    For Each line As String In lines
        Dim columns() As String = line.Split(","c)
        Dim Year As String = columns(0)
        Dim Quarter As String = columns(1)
    Next
    

    However, sometimes CSV isn’t that simple. For instance, a cell in a spreadsheet could contain a comma character, in which case it would be represented in CSV like this:

    example cell 1,"example, with comma",example cell 3
    

    To make sure you’re properly handling all possibilities, I’d recommend using the TextFieldParser class. For instance:

    Using parser As New TextFieldParser(New StringReader(strBuffer))
        parser.TextFieldType = FieldType.Delimited
        parser.SetDelimiters(",")
        While Not parser.EndOfData
            Try
                Dim columns As String() = parser.ReadFields()
                Dim Year As String = columns(0)
                Dim Quarter As String = columns(1)
            Catch ex As MalformedLineException
                ' Handle the invalid formatting error
            End Try 
        End While 
    End Using
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CSV (comma separated values) file that contains student information. The column
I have a string ($c) that contains a comma-separated list of settings. Some settings
If I have a string that contains the html from a page I just
I have a std::string that contains comma separated values, i need to store those
I have a string that contains comma seperated email addresses. I then load this
I have a comma delimited string held within a database field that could contain
I have a string that contains source code of an other groovy file in
I have a text file that contains more or less paragraphs. The text is
i have string that contains apostrophe and comma's and when i execute insert into
I have a string that contains HTML image elements that is stored in a

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.