473,387 Members | 1,481 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.

Dumping CSV file into a Array in vb.net 2005

20
Hello,

I want to place the contents of a CSV file into an array.

The csv file looks as follows:

CG.A1300.CB24.KREG176E,BEYYMMDD
CG.A1300.CB24.KREG176F,BFYYMMDD
CG.A1300.CB24.KREG90,BBYYMMDD
CG.A1300.CB24.KRG8183E,BDYYMMDD
CG.A1300.CB24.KPRODCON.RPT,BRYYMMDD

I want to put this into an array, but I need it to be split on the Comma so that the final result is the following.


Array(0,0) shows: CG.A1300.CB24.KREG176E
Array(0,1) shows: BEYYMMDD

And so on.

My code currently is this:
Expand|Select|Wrap|Line Numbers
  1. Dim Templookup() As String
  2.         Dim reader As StreamReader
  3.         Dim X, I As Integer
  4.  
  5.         'Load the Lookup.csv.
  6.         reader = New StreamReader("D:\Enbridgefiletest\Removable Hard drive\lookup.csv")
  7.         X = 0
  8.         Do
  9.  
  10.             ReDim Preserve Templookup(X)
  11.             Templookup(X) = reader.ReadLine
  12.             X = X + 1
  13.         Loop Until reader.EndOfStream
  14.         Dim lookup(X, 1) As String
  15.         I = 0
  16.  
I have not yet placed anything into an array or split it, I was trying a number of combinations but can’t seem to figure it out.

Any help would be great!
Oct 10 '07 #1
2 1593
Plater
7,872 Expert 4TB
If you read it all in as a string, you can .Split("\r\n".ToCharArray()) (on newlines) and get an array of the lines.
Then you can .Split(",".ToCharArray()) (on commas) each of those entries to produce another array for each of the lines.

Or you can read the file in one line at a time and do the .Split() for commas on them.
Oct 10 '07 #2
Javilen
20
Thanks for the help, I will try your way out.
Oct 10 '07 #3

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

Similar topics

6
by: matt | last post by:
I am using a text file as a database, each field delimited by || I want to be able to print all lines to a page, then by selecting one (with, say, a radio button) it will load into the form at the...
5
by: mostof | last post by:
I'm facing a problem with require_once... Instead of actually including the file i'm requiring, it just dumps it out as text... other functions are working quite well... the code look like...
11
by: alex | last post by:
Hi, I am looking for a way to populate an HTML table from an external local text file which looks like this: DATE/TIME LAT. LON. DEPTH. ML....
6
by: Greg Brant | last post by:
Hi, how can i backup a table / entire DB and get the index's as well as the data / create table's etc cheers Greg
4
by: rozrabiak | last post by:
Hi:) I need to dump data from database in to *.sql file. I try it using DUMP DATABASE but it not work that I need it. So, how can I dump data from database in to *.sql file and then run it...
2
by: mr.kuhl | last post by:
I thought I would contribute a solution for once. We have a standard SUSE LAMP (Linux Apache Mysql PHP) server running some custom apps, of which one component is dumping reports out to excel. ...
10
by: ken | last post by:
hello, i'm writing a c program on a linux system. i'm debugging a segmentation fault but i don't want it to dump a core file because the memory footprint of the program is over 300Mb and i don't...
9
by: steph_de_marseille | last post by:
I would like to write a x array in a file. If the array has a small numbers of columns I know I can use a loop like: int i,j; double array; FILE *file1; file1=fopen("data.dat","w");...
1
by: lactaseman | last post by:
While I know this is not the correct venue... I realize this is of little to no importance to most out there... however, if I had found this in my initial searches, I would have used this. So, as...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.