compositeList.Add(Line.Split(",")(0).Trim(New Char() {""""}).ToLower)
How to Remove Quotes Surrounding Text Returned From CSV File Parse
-
29-07-2022 - |
Question
I am using the code below to compile a list of ticker symbols on the NASDAQ stock exchange. I am using the CSV file located here: http://www.nasdaq.com/screening/companies-by-industry.aspx?exchange=NASDAQ&render=download
When I open the CSV file in Excel there are no quotation marks around the ticker symbols. But when I run the code below. All of the ticker symbols returned to my list have quotation marks around them. Why is this? And how do I get rid of the quotation marks?
Here is my code:
Public Shared tickerList As New List(Of String)
Dim compositeList As New List(Of String)
Dim strBuffer As String
strBuffer = Historical_Stock_Prices.RequestWebData(http://www.nasdaq.com/screening/companies-by-industry.aspx?exchange=NASDAQ&render=download)
Dim sReader As New StringReader(strBuffer)
Dim Line_List As New List(Of String)
Do While sReader.Peek >= 0
Line_List.Add(sReader.ReadLine)
Loop
Line_List.RemoveAt(0)
For Each Line In Line_List
compositeList.Add(Line.Split(",")(0).Trim.ToLower)
Next
sReader.Close()
tickerList = compositeList.Distinct.ToList
tickerList.Sort()
Solution
OTHER TIPS
myString = myString.Substring(1, myString.Length -1)
That will remove first and last characters.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow