473,769 Members | 8,305 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading in .csv files

Hi, i am new to VB.Net and really enjoying the trip so far =)

However I have this problem:
I was wondering if anyone is familiar with how to go about reading in an
Excel ".csv" file? I had a search on the internet and found some VB6 code
examples, but i don't think VB6 code is the same as VB.Net is it?

I basically need to read the file in, storing the data (which is arranged in
columns) into a 2Dimensional array.
From there i want to write that data to a database table (most likely
Access) for permanent storage. Any future oeprations on the data (such as
search, edit) will reference the database table i wrote to.

I am familiar with using things like a StringTokenizer in Java, loops and
reading file in, but what do we have available in VB.Net? And should i take
note of the VB6 examples i found or start from scratch?
Any help or reference links is greatly appreciated!

Regards
Nick Hoare
Jul 19 '05 #1
2 10929
Nick,
The closest thing to StringTokenizer in .NET is String.Split.

There are actually three Split functions in VB.NET:

Use Microsoft.Visua lBasic.Strings. Split if you need to split a string based
on a specific word (string). It is the Split function from VB6.

Use System.String.S plit if you need to split a string based on a collection
of specific characters. Each individual character is its own delimiter.

Alternatively use System.Text.Reg ularExpressions .RegEx.Split to split based
on matching patterns.

Hope this helps
Jay
"Nick Hoare" <ho*********@ho tmail.com> wrote in message
news:tQ******** ***********@new s-server.bigpond. net.au...
Hi, i am new to VB.Net and really enjoying the trip so far =)

However I have this problem:
I was wondering if anyone is familiar with how to go about reading in an
Excel ".csv" file? I had a search on the internet and found some VB6 code
examples, but i don't think VB6 code is the same as VB.Net is it?

I basically need to read the file in, storing the data (which is arranged in columns) into a 2Dimensional array.
From there i want to write that data to a database table (most likely
Access) for permanent storage. Any future oeprations on the data (such as
search, edit) will reference the database table i wrote to.

I am familiar with using things like a StringTokenizer in Java, loops and
reading file in, but what do we have available in VB.Net? And should i take note of the VB6 examples i found or start from scratch?
Any help or reference links is greatly appreciated!

Regards
Nick Hoare

Jul 19 '05 #2
Hi Nick,

Can you save the data in the excel file as XML, if you can you can read it
directly into a data adapter using the ReadXML function.

Cheers
Andrew
"Nick Hoare" <ho*********@ho tmail.com> wrote in message
news:tQ******** ***********@new s-server.bigpond. net.au...
Hi, i am new to VB.Net and really enjoying the trip so far =)

However I have this problem:
I was wondering if anyone is familiar with how to go about reading in an
Excel ".csv" file? I had a search on the internet and found some VB6 code
examples, but i don't think VB6 code is the same as VB.Net is it?

I basically need to read the file in, storing the data (which is arranged in columns) into a 2Dimensional array.
From there i want to write that data to a database table (most likely
Access) for permanent storage. Any future oeprations on the data (such as
search, edit) will reference the database table i wrote to.

I am familiar with using things like a StringTokenizer in Java, loops and
reading file in, but what do we have available in VB.Net? And should i take note of the VB6 examples i found or start from scratch?
Any help or reference links is greatly appreciated!

Regards
Nick Hoare

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2821
by: Olivier Maurice | last post by:
Hi all, I suppose some of you know the program Redmon (type redmon in google, first result). This neat little tool allows to hook up any functionality to a printer by putting the file printed to the printer to standard in. You have to provide yourself the program that does something with that data, so I thought with some quick c/c++ programming that would be no problem. I tried dozens of ways of reading the data from stdin or cin,...
19
10375
by: Lionel B | last post by:
Greetings, I need to read (unformatted text) from stdin up to EOF into a char buffer; of course I cannot allocate my buffer until I know how much text is available, and I do not know how much text is available until I have read it... which seems to imply that multiple reads of the input stream will be inevitable. Now I can correctly find the number of characters available by: |
1
6761
by: Magnus | last post by:
allrite folks, got some questions here... 1) LAY-OUT OF REPORTS How is it possible to fundamentaly change the lay-out/form of a report in access? I dont really know it that "difficult", but listen up; Reports, the way I look at them, all present data downwards, in this way; TITLE data
6
6371
by: Rajorshi Biswas | last post by:
Hi folks, Suppose I have a large (1 GB) text file which I want to read in reverse. The number of characters I want to read at a time is insignificant. I'm confused as to how best to do it. Upon browsing through this group and other sources on the web, it seems that there are many ways to do it. Some suggest that simply fseek'ing to 8K bytes before the end of file, and going backwards is the way. In this case, am I guaranteed best results...
2
3252
by: nnimod | last post by:
Hi. I'm having trouble reading some unicode files. Basically, I have to parse certain files. Some of those files are being input in Japanese, Chinese etc. The easiest way, I figured, to distinguish between plain ASCII files I receive and the Unicode ones would be to check if the first two bytes read 0xFFFE. But nothing I do seems to be able to do that. I tried reading it in binary mode and reading two characters in:
7
5560
by: jccorreu | last post by:
I've got to read info from multiple files that will be given to me. I know the format and what the data is. The thing is each time we run the program we may be using a differnt number of files, with different file names each time. So i'm writing into the code to ask the user how many files, and what their names are. From each we'll read in 2 lines, then do some math using all of those lines. Then do it again on another set of lines. ...
6
5273
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
10
8357
by: Tyler | last post by:
Hello All: After trying to find an open source alternative to Matlab (or IDL), I am currently getting acquainted with Python and, in particular SciPy, NumPy, and Matplotlib. While I await the delivery of Travis Oliphant's NumPy manual, I have a quick question (hopefully) regarding how to read in Fortran written data. The data files are not binary, but ASCII text files with no formatting and mixed data types (strings, integers,...
5
14992
blazedaces
by: blazedaces | last post by:
Ok, so you know my problem, java is running out of memory reading with SAX, the event-based xml parser intended more-so than DOM for extremely large files. I'll try to explain what I've been doing and why I have to do it. Hopefully someone has a suggestion... Alright, so I'm using a gps-simulation program that outputs gps data, like longitude, lattitude, altitude, etc. (hundreds of terms, these are just the well known ones). In the newer...
4
1900
by: Miner Jeff | last post by:
Hello, I have a basic question about reading files. I have several data files where the filenames are identical except for a short (3 character) prefix. I inherited this code and the person who developed it was making a duplicate of each file and then deleting the prefix on the copied file so the following statement could read a generic "filename":
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10219
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.