473,387 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Writing a csv file to a List(Of String)

I split a csv file to parts: the buyer_name and buyer_key.
My next goal is to save this two in an list(of string)with indices zero and one as i iterate through the cvs file.
This is the code:
Expand|Select|Wrap|Line Numbers
  1. Public Function InitializeBuyerKeys()
  2.         Dim BuyerList(2) As List(Of String)
  3.        Dim sr As StreamReader = New StreamReader("C:\Users\Harrison pc\Documents\harrison\BuyersKeyList.csv")
  4.         Dim strLine As String = String.Empty
  5.  
  6.         Do While sr.Peek() >= 0
  7.             strLine = String.Empty
  8.             strLine = sr.ReadLine()
  9.  
  10.             Dim reader As StringReader = New StringReader(strLine.ToString())
  11.             Dim currentLine As String = reader.ReadLine()
  12.  
  13.             Dim buyer_name As String = currentLine.Split(",")(0)
  14.             BuyerList(0).Add(buyer_name)
  15.             ' MessageBox.Show(List.ToString)
  16.  
  17.             Dim buyer_key As String = currentLine.Split(",")(1)
  18.             BuyerList(1).Add(buyer_key)
  19.             ' MessageBox.Show(List.ToString)
  20.  
  21.  
  22.  
  23.         Loop
  24.         Return BuyerList.ToString
Please help. I'm having an error of nullexception.
May 5 '16 #1
0 1161

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Michael Weir | last post by:
I'm sure this is a very simple thing to do, once you know how to do it, but I am having no fun at all trying to write utf-8 strings to a unicode file. Does anyone have a couple of lines of code...
0
by: JC | last post by:
I am using Mysql version: 4.0.18-max-log and trying to populate a database from a text file using source option from inside the mysql environment. The population run OK but when creating the...
60
by: Julie | last post by:
What is the *fastest* way in .NET to search large on-disk text files (100+ MB) for a given string. The files are unindexed and unsorted, and for the purposes of my immediate requirements, can't...
5
by: feng | last post by:
OK, all I want is writting a string that represents an XML document into a file, say C:\test.xml. This kind of task used to be so easy with vb6. But now, with VB.Net, it seems turned into a big...
2
by: Trint Smith | last post by:
How can I store an entire html file in a string with all it's formating, double quotes, multiple lines and all?? like this: Dim FileString As String = ENTIRE HTML FILE thanks, Trint .Net...
4
by: kenny | last post by:
Hello, I am trying to read the contents of 01.bin (unicode) into a String, to modify it and finally to write it back into an other file named 02.bin. If the file really contains "a b c", then...
4
by: FingerDemon | last post by:
I'm guessing I'm missing something obvious here, but I have searched around and re-read my Python books and references on simple file writing and I can't see the answer. I am running this in Windows...
1
by: Mr fahad | last post by:
#include <stdio.h> #include <conio.h> void main (void) { char ch; FILE *fp; fp=fopen ("fahd.txt","w"); while (ch=fgetc( )!='\r') fputc (ch,fp); fclose (fp);
3
by: jain236 | last post by:
Hi , i have file of 32kb , i want to read the whole file into string , i tried this by doing the below code, but i dint got the whole content of the file in the string , i guess the variable is not...
2
by: =?Utf-8?B?S3VtYXI=?= | last post by:
I am using granados telnet client for connecting to the telnet and get the data from it. Every thing appears to be going smooth. But for some reason when I try to write the byte data to a string or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.