Question

I need download a CSV file and then read it. Here is my code:

tickerValue = "goog"
Dim strURL As String = "http://ichart.yahoo.com/table.csv?s=" & tickerValue
Dim strBuffer As String = RequestWebData(strURL)
Using streamReader = New StreamReader(strBuffer)
Using reader = New CsvReader(streamReader)

I keep getting this error: An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll Additional information: Illegal characters in path.

What am I doing wrong?

Additional Info

In another part of my program I use this code and it works fine.

Address = http://www.nasdaq.com/screening/companies-by-industry.aspx?exchange=AMEX&render=download
Dim strBuffer As String = Historical_Stock_Prices.RequestWebData(Address)
Using streamReader = New StringReader(strBuffer)
Using reader = New CsvReader(streamReader)

Isn't my second code the same concept as my problem code?

Was it helpful?

Solution

you are giving it, essentially, a web url. somewhere in your code, it does not support the web url. it could be the streamreader. it could be the CsvReader. what line of code does this point to?

the best bet is to save the file TO DISK, then read from disk.

UPDATE

here is an example to SAVE to disk:

using writer as new StreamWriter("C:\Test.csv")
   writer.Write(strBuffer)
   writer.Close()
end using

here is an example to READ from disk:

using strReader as new StreamReader("C:\Test.csv")
   ' this code is presumably how it works for reading into the CsvReader:
   using reader as new CsvReader(strReader)
      ' now do your thing
   end using
   strReader.Close()
end using
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top