473,383 Members | 1,862 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,383 software developers and data experts.

Text files

I have a | (pipe) delimited file that i need to import in to a Dataset. With
code below i get 7 items in the first column of each row and the rest is
empty. PLEASE HELP

Below if the code that does it.

For it to work i needed an ini file with columns defined and at the top of
the ini these options are set

[c125788_1_fi_011404_001.txt]
ColNameHeader=False
Format=CSVDelimited
MaxScanRows=25
CharacterSet=ANSI
<-----------------VB Code------
Dim FilePath As String = "C:\ftproot\TOG\"

Dim Conn As New
System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;Data
Source=" & FilePath & ";Extended Properties=""text;HDR=NO;FMT=Delimited""")

Dim Comm As New System.Data.OleDb.OleDbDataAdapter("select * from
c125788_1_fi_011404_001.txt", Conn)

Dim DS As New DataSet

Try

Comm.Fill(DS)

Catch e As Exception

End Try

Conn.Close()

Dim i As Integer = DS.Tables(0).Rows.Count

End Sub
Nov 20 '05 #1
2 1251

"Ruslan Shlain" <rs*****@hotmail.com> wrote in message
news:O8**************@TK2MSFTNGP10.phx.gbl...
I have a | (pipe) delimited file that i need to import in to a Dataset. With code below i get 7 items in the first column of each row and the rest is
empty. PLEASE HELP

Below if the code that does it.

For it to work i needed an ini file with columns defined and at the top of
the ini these options are set

[c125788_1_fi_011404_001.txt]
ColNameHeader=False
Format=CSVDelimited
MaxScanRows=25
CharacterSet=ANSI
<-----------------VB Code------
Dim FilePath As String = "C:\ftproot\TOG\"

Dim Conn As New
System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;Data
Source=" & FilePath & ";Extended Properties=""text;HDR=NO;FMT=Delimited""")
Dim Comm As New System.Data.OleDb.OleDbDataAdapter("select * from
c125788_1_fi_011404_001.txt", Conn)

Dim DS As New DataSet

Try

Comm.Fill(DS)

Catch e As Exception

End Try

Conn.Close()

Dim i As Integer = DS.Tables(0).Rows.Count

End Sub

Off the hip....
Forget the Connection and DataAdapter. Create a DataTable, then, using a
rows and column object, add you're rows. To step backward, make a string(),
read each line in and use a Split function to seperate those suckers out,
then add them to the table, adding the table to the DataSet. That would be
my solution.

HTH
Sueffel
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004
Nov 20 '05 #2
On Wed, 14 Jan 2004 15:44:20 -0600, "Ruslan Shlain" <rs*****@hotmail.com> wrote:

¤ I have a | (pipe) delimited file that i need to import in to a Dataset. With
¤ code below i get 7 items in the first column of each row and the rest is
¤ empty. PLEASE HELP
¤
¤ Below if the code that does it.
¤
¤ For it to work i needed an ini file with columns defined and at the top of
¤ the ini these options are set
¤
¤ [c125788_1_fi_011404_001.txt]
¤ ColNameHeader=False
¤ Format=CSVDelimited
¤ MaxScanRows=25
¤ CharacterSet=ANSI
¤

You might want to post the first ten or twenty lines of your text file if possible.

BTW, if the delimiter is a pipe character then you will need to change the Format argument in your
schema.ini file to:

Format=Delimited(|)
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 20 '05 #3

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

Similar topics

27
by: Eric | last post by:
Assume that disk space is not an issue (the files will be small < 5k in general for the purpose of storing preferences) Assume that transportation to another OS may never occur. Are there...
0
by: Steve | last post by:
My application uses transfertext to create text files that are FTPed to a website and are processed by a webstore. The text files can be for one of three purposes: Add one or more items to the...
16
by: thenightfly | last post by:
Ok, I know all about how binary numbers translate into text characters. My question is what exactly IS a text character? Is it a bitmap?
0
by: richardkreidl | last post by:
I have the following hash script that I use to compare two text files. 'Class Public Class FileComparison Public Class FileComparisonException Public Enum ExceptionType U 'Unknown A 'Add...
3
by: Frustrated Developer via DotNetMonster.com | last post by:
I have posted a couple times on here already and found the user community to be very helpful. I took on a project before I realized how difficult a time I'm having working with a database....
10
by: joelagnel | last post by:
hi friends, i've been having this confusion for about a year, i want to know the exact difference between text and binary files. using the fwrite function in c, i wrote 2 bytes of integers in...
5
by: praveenholal | last post by:
Hi Freinds , I want to convert the files that are in text format (.txt) to CSV file. I am working on Linux. So can anyone guide me. Here is my problem Description I have some result files...
29
by: list | last post by:
Hi folks, I am new to Googlegroups. I asked my questions at other forums, since now. I have an important question: I have to check files if they are binary(.bmp, .avi, .jpg) or text(.txt,...
1
by: Xah Lee | last post by:
Text Processing with Emacs Lisp Xah Lee, 2007-10-29 This page gives a outline of how to use emacs lisp to do text processing, using a specific real-world problem as example. If you don't know...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.